Reviewers: ,
Please review this at http://codereview.tryton.org/932002/
Affected files:
A trytond/modules/purchase/invoice.xml
M trytond/modules/purchase/purchase.py
M trytond/modules/sale/__init__.py
A trytond/modules/sale/invoice.xml
M trytond/modules/sale/sale.py
A trytond/modules/sale/stock.py
trytond/modules/sale/stock.xml
M trytond/modules/sale/tryton.cfg
Index: trytond/modules/purchase/invoice.xml
===================================================================
new file mode 100644
--- /dev/null
+++ b/trytond/modules/purchase/invoice.xml
@@ -0,0 +1,19 @@
+<?xml version="1.0"?>
+<!-- This file is part of Tryton. The COPYRIGHT file at the top level of
+this repository contains the full copyright notices and license terms. -->
+<tryton>
+ <data>
+ <record model="ir.action.act_window" id="act_purchase_relate_form">
+ <field name="name">Purchases</field>
+ <field name="res_model">purchase.purchase</field>
+ <field name="domain">[("id", "in", Eval('purchases'))]</field>
+ </record>
+ <record model="ir.action.keyword"
+ id="act_open_purchase_relate_keyword">
+ <field name="keyword">form_relate</field>
+ <field name="model">account.invoice,-1</field>
+ <field name="action" ref="act_purchase_relate_form"/>
+ </record>
+ </data>
+</tryton>
+
Index: trytond/modules/purchase/purchase.py
===================================================================
--- a/trytond/modules/purchase/purchase.py
+++ b/trytond/modules/purchase/purchase.py
@@ -615,7 +615,6 @@
return Invoice(
company=self.company,
type=invoice_type,
- reference=self.reference,
journal=journal,
party=self.party,
invoice_address=self.invoice_address,
@@ -672,7 +671,6 @@
with Transaction().set_user(0, set_context=True):
return ShipmentInReturn(
company=self.company,
- reference=self.reference,
from_location=self.warehouse.storage_location,
to_location=self.party.supplier_location,
)
Index: trytond/modules/sale/__init__.py
===================================================================
--- a/trytond/modules/sale/__init__.py
+++ b/trytond/modules/sale/__init__.py
@@ -5,6 +5,7 @@
from .sale import *
from .configuration import *
from .invoice import *
+from .stock import *
def register():
@@ -33,6 +34,7 @@
HandleShipmentException,
HandleInvoiceException,
ReturnSale,
+ ShipmentOutSaleRelate,
module='sale', type_='wizard')
Pool.register(
SaleReport,
Index: trytond/modules/sale/invoice.xml
===================================================================
new file mode 100644
--- /dev/null
+++ b/trytond/modules/sale/invoice.xml
@@ -0,0 +1,18 @@
+<?xml version="1.0"?>
+<!-- This file is part of Tryton. The COPYRIGHT file at the top level of
+this repository contains the full copyright notices and license terms. -->
+<tryton>
+ <data>
+ <record model="ir.action.act_window" id="act_sale_relate_form">
+ <field name="name">Sales</field>
+ <field name="res_model">sale.sale</field>
+ <field name="domain">[("id", "in", Eval('sales'))]</field>
+ </record>
+ <record model="ir.action.keyword"
+ id="act_open_sale_relate_keyword">
+ <field name="keyword">form_relate</field>
+ <field name="model">account.invoice,-1</field>
+ <field name="action" ref="act_sale_relate_form"/>
+ </record>
+ </data>
+</tryton>
Index: trytond/modules/sale/sale.py
===================================================================
--- a/trytond/modules/sale/sale.py
+++ b/trytond/modules/sale/sale.py
@@ -674,7 +674,6 @@
return Invoice(
company=self.company,
type=invoice_type,
- reference=self.reference,
journal=journal,
party=self.party,
invoice_address=self.invoice_address,
@@ -767,7 +766,6 @@
values = {
'customer': self.party.id,
'delivery_address': self.shipment_address.id,
- 'reference': self.reference,
'company': self.company.id,
}
values.update(dict(key))
Index: trytond/modules/sale/stock.py
===================================================================
new file mode 100644
--- /dev/null
+++ b/trytond/modules/sale/stock.py
@@ -0,0 +1,33 @@
+# This file is part of Tryton. The COPYRIGHT file at the top level of this
+# repository contains the full copyright notices and license terms.
+
+from trytond.wizard import Wizard, StateAction
+from trytond.pyson import PYSONEncoder
+from trytond.pool import Pool
+from trytond.transaction import Transaction
+
+__all__ = ['ShipmentOutSaleRelate']
+
+
+class ShipmentOutSaleRelate(Wizard):
+ 'Shipment Out to Sale Relate'
+ __name__ = 'stock.shipment.out.sale_relate'
+
+ start = StateAction('sale.act_sale_form')
+
+ def do_start(self, action):
+ ShipmentOut = Pool().get('stock.shipment.out')
+ SaleLine = Pool().get('sale.line')
+ shipments = ShipmentOut.browse(Transaction().context['active_ids'])
+ sale_ids = set()
+ for shipment in shipments:
+ for move in shipment.outgoing_moves:
+ if isinstance(move.origin, SaleLine):
+ sale_ids.add(move.origin.sale.id)
+ action['pyson_domain'] = PYSONEncoder().encode([
+ ('id', 'in', list(sale_ids)),
+ ])
+ return action, {}
+
+ def transition_start(self):
+ return 'end'
Index: trytond/modules/sale/stock.xml
===================================================================
--- a/trytond/modules/sale/stock.xml
+++ b/trytond/modules/sale/stock.xml
@@ -9,5 +9,16 @@
<field name="priority" eval="20"/>
<field name="name">move_list_shipment</field>
</record>
+
+ <record model="ir.action.wizard" id="wizard_shipment_sale_relate">
+ <field name="name">Sales</field>
+ <field name="wiz_name">stock.shipment.out.sale_relate</field>
+ <field name="model">stock.shipment.out</field>
+ </record>
+ <record model="ir.action.keyword" id="act_open_sale_keyword">
+ <field name="keyword">form_relate</field>
+ <field name="model">stock.shipment.out,-1</field>
+ <field name="action" ref="wizard_shipment_sale_relate"/>
+ </record>
</data>
</tryton>
Index: trytond/modules/sale/tryton.cfg
===================================================================
--- a/trytond/modules/sale/tryton.cfg
+++ b/trytond/modules/sale/tryton.cfg
@@ -17,3 +17,4 @@
party.xml
stock.xml
product.xml
+ invoice.xml