changeset 6a6b4ef53946 in modules/purchase:default
details: https://hg.tryton.org/modules/purchase?cmd=changeset;node=6a6b4ef53946
description:
Add symbol widget
issue9059
review276871002
diffstat:
product.py | 33 ++++++++++++++++++++++----
purchase.py | 8 ++++++
view/move_list_shipment.xml | 3 +-
view/product_supplier_form.xml | 1 +
view/product_supplier_price_form.xml | 4 +-
view/product_supplier_price_list_sequence.xml | 4 +-
view/product_supplier_price_tree.xml | 4 +-
view/purchase_form.xml | 6 ++--
view/purchase_line_form.xml | 4 +-
view/purchase_line_tree.xml | 7 ++---
view/purchase_line_tree_sequence.xml | 7 ++---
view/purchase_tree.xml | 3 +-
12 files changed, 56 insertions(+), 28 deletions(-)
diffs (228 lines):
diff -r 085a59108214 -r 6a6b4ef53946 product.py
--- a/product.py Sun Oct 04 23:54:46 2020 +0200
+++ b/product.py Fri Oct 09 19:09:05 2020 +0200
@@ -271,6 +271,8 @@
lead_time = fields.TimeDelta('Lead Time')
currency = fields.Many2One('currency.currency', 'Currency', required=True,
ondelete='RESTRICT')
+ uom = fields.Function(
+ fields.Many2One('product.uom', "UOM"), 'on_change_with_uom')
@classmethod
def __register__(cls, module_name):
@@ -360,12 +362,16 @@
]
return domain
- @property
- def uom(self):
+ @fields.depends(
+ 'product', '_parent_product.purchase_uom',
+ 'template', '_parent_template.purchase_uom')
+ def on_change_with_uom(self, name=None):
if self.product:
- return self.product.purchase_uom
- else:
- return self.template.purchase_uom
+ if self.product.purchase_uom:
+ return self.product.purchase_uom.id
+ elif self.template:
+ if self.template.purchase_uom:
+ return self.template.purchase_uom.id
def compute_supply_date(self, date=None):
'''
@@ -412,6 +418,13 @@
unit_price = fields.Numeric('Unit Price', required=True,
digits=price_digits)
+ uom = fields.Function(fields.Many2One('product.uom', 'UOM',
+ help="The unit in which the quantity is specified."),
+ 'on_change_with_uom')
+ currency = fields.Function(
+ fields.Many2One('currency.currency', 'Currency'),
+ 'on_change_with_currency')
+
@classmethod
def __register__(cls, module_name):
cursor = Transaction().connection.cursor()
@@ -431,6 +444,16 @@
def default_quantity():
return 0.0
+ @fields.depends('product_supplier', '_parent_product_supplier.product')
+ def on_change_with_uom(self, name=None):
+ if self.product_supplier and self.product_supplier.uom:
+ return self.product_supplier.uom.id
+
+ @fields.depends('product_supplier', '_parent_product_supplier.currency')
+ def on_change_with_currency(self, name=None):
+ if self.product_supplier and self.product_supplier.currency:
+ return self.product_supplier.currency.id
+
@staticmethod
def get_pattern():
return {}
diff -r 085a59108214 -r 6a6b4ef53946 purchase.py
--- a/purchase.py Sun Oct 04 23:54:46 2020 +0200
+++ b/purchase.py Fri Oct 09 19:09:05 2020 +0200
@@ -1154,6 +1154,9 @@
company = fields.Function(
fields.Many2One('company.company', "Company"),
'on_change_with_company')
+ currency = fields.Function(
+ fields.Many2One('currency.currency', 'Currency'),
+ 'on_change_with_currency')
@classmethod
def __register__(cls, module_name):
@@ -1437,6 +1440,11 @@
if self.purchase and self.purchase.company:
return self.purchase.company.id
+ @fields.depends('purchase', '_parent_purchase.currency')
+ def on_change_with_currency(self, name=None):
+ if self.purchase and self.purchase.currency:
+ return self.purchase.currency.id
+
def get_invoice_line(self):
'Return a list of invoice line for purchase line'
pool = Pool()
diff -r 085a59108214 -r 6a6b4ef53946 view/move_list_shipment.xml
--- a/view/move_list_shipment.xml Sun Oct 04 23:54:46 2020 +0200
+++ b/view/move_list_shipment.xml Fri Oct 09 19:09:05 2020 +0200
@@ -5,8 +5,7 @@
<field name="product" expand="1"/>
<field name="from_location" expand="1"/>
<field name="to_location" expand="1"/>
- <field name="quantity"/>
- <field name="uom"/>
+ <field name="quantity" symbol="uom"/>
<field name="state"/>
<field name="purchase_exception_state"/>
<button name="cancel"/>
diff -r 085a59108214 -r 6a6b4ef53946 view/product_supplier_form.xml
--- a/view/product_supplier_form.xml Sun Oct 04 23:54:46 2020 +0200
+++ b/view/product_supplier_form.xml Fri Oct 09 19:09:05 2020 +0200
@@ -21,4 +21,5 @@
<field name="currency"/>
<field name="prices" colspan="4"
view_ids="purchase.product_supplier_price_view_list_sequence"/>
+ <field name="uom" colspan="4" invisible="1"/>
</form>
diff -r 085a59108214 -r 6a6b4ef53946 view/product_supplier_price_form.xml
--- a/view/product_supplier_price_form.xml Sun Oct 04 23:54:46 2020 +0200
+++ b/view/product_supplier_price_form.xml Fri Oct 09 19:09:05 2020 +0200
@@ -7,8 +7,8 @@
<label name="sequence"/>
<field name="sequence"/>
<label name="quantity"/>
- <field name="quantity"/>
+ <field name="quantity" symbol="uom"/>
<newline/>
<label name="unit_price"/>
- <field name="unit_price"/>
+ <field name="unit_price" symbol="currency"/>
</form>
diff -r 085a59108214 -r 6a6b4ef53946
view/product_supplier_price_list_sequence.xml
--- a/view/product_supplier_price_list_sequence.xml Sun Oct 04 23:54:46
2020 +0200
+++ b/view/product_supplier_price_list_sequence.xml Fri Oct 09 19:09:05
2020 +0200
@@ -3,6 +3,6 @@
this repository contains the full copyright notices and license terms. -->
<tree sequence="sequence">
<field name="product_supplier" expand="1"/>
- <field name="quantity"/>
- <field name="unit_price" expand="1"/>
+ <field name="quantity" symbol="uom"/>
+ <field name="unit_price" symbol="currency" expand="1"/>
</tree>
diff -r 085a59108214 -r 6a6b4ef53946 view/product_supplier_price_tree.xml
--- a/view/product_supplier_price_tree.xml Sun Oct 04 23:54:46 2020 +0200
+++ b/view/product_supplier_price_tree.xml Fri Oct 09 19:09:05 2020 +0200
@@ -3,6 +3,6 @@
this repository contains the full copyright notices and license terms. -->
<tree>
<field name="product_supplier" expand="1"/>
- <field name="quantity"/>
- <field name="unit_price"/>
+ <field name="quantity" symbol="uom"/>
+ <field name="unit_price" symbol="currency"/>
</tree>
diff -r 085a59108214 -r 6a6b4ef53946 view/purchase_form.xml
--- a/view/purchase_form.xml Sun Oct 04 23:54:46 2020 +0200
+++ b/view/purchase_form.xml Fri Oct 09 19:09:05 2020 +0200
@@ -39,11 +39,11 @@
</group>
<group col="2" colspan="2" id="amount" yfill="1">
<label name="untaxed_amount" xalign="1.0" xexpand="1"/>
- <field name="untaxed_amount" xalign="1.0" xexpand="0"/>
+ <field name="untaxed_amount" symbol="currency" xalign="1.0"
xexpand="0"/>
<label name="tax_amount" xalign="1.0" xexpand="1"/>
- <field name="tax_amount" xalign="1.0" xexpand="0"/>
+ <field name="tax_amount" symbol="currency" xalign="1.0"
xexpand="0"/>
<label name="total_amount" xalign="1.0" xexpand="1"/>
- <field name="total_amount" xalign="1.0" xexpand="0"/>
+ <field name="total_amount" symbol="currency" xalign="1.0"
xexpand="0"/>
</group>
</page>
<page string="Other Info" id="info">
diff -r 085a59108214 -r 6a6b4ef53946 view/purchase_line_form.xml
--- a/view/purchase_line_form.xml Sun Oct 04 23:54:46 2020 +0200
+++ b/view/purchase_line_form.xml Fri Oct 09 19:09:05 2020 +0200
@@ -20,9 +20,9 @@
<label name="unit"/>
<field name="unit"/>
<label name="unit_price"/>
- <field name="unit_price"/>
+ <field name="unit_price" symbol="currency"/>
<label name="amount"/>
- <field name="amount"/>
+ <field name="amount" symbol="currency"/>
<label id="delivery_date" string="Delivery Date:"/>
<group id="delivery_date" col="-1">
<field name="delivery_date" xexpand="0"/>
diff -r 085a59108214 -r 6a6b4ef53946 view/purchase_line_tree.xml
--- a/view/purchase_line_tree.xml Sun Oct 04 23:54:46 2020 +0200
+++ b/view/purchase_line_tree.xml Fri Oct 09 19:09:05 2020 +0200
@@ -6,9 +6,8 @@
<field name="type"/>
<field name="product" expand="1"/>
<field name="product_supplier" expand="1"/>
- <field name="quantity"/>
- <field name="unit"/>
- <field name="unit_price"/>
+ <field name="quantity" symbol="unit"/>
+ <field name="unit_price" symbol="currency"/>
<field name="taxes"/>
- <field name="amount"/>
+ <field name="amount" symbol="currency"/>
</tree>
diff -r 085a59108214 -r 6a6b4ef53946 view/purchase_line_tree_sequence.xml
--- a/view/purchase_line_tree_sequence.xml Sun Oct 04 23:54:46 2020 +0200
+++ b/view/purchase_line_tree_sequence.xml Fri Oct 09 19:09:05 2020 +0200
@@ -6,9 +6,8 @@
<field name="type"/>
<field name="product" expand="1"/>
<field name="product_supplier" expand="1"/>
- <field name="quantity"/>
- <field name="unit"/>
- <field name="unit_price"/>
+ <field name="quantity" symbol="unit"/>
+ <field name="unit_price" symbol="currency"/>
<field name="taxes"/>
- <field name="amount"/>
+ <field name="amount" symbol="currency"/>
</tree>
diff -r 085a59108214 -r 6a6b4ef53946 view/purchase_tree.xml
--- a/view/purchase_tree.xml Sun Oct 04 23:54:46 2020 +0200
+++ b/view/purchase_tree.xml Fri Oct 09 19:09:05 2020 +0200
@@ -7,8 +7,7 @@
<field name="purchase_date"/>
<field name="party" expand="2"/>
<field name="warehouse"/>
- <field name="currency"/>
- <field name="untaxed_amount"/>
+ <field name="untaxed_amount" symbol="currency"/>
<field name="state"/>
<field name="invoice_state"/>
<field name="shipment_state"/>