changeset d5bd02d543d5 in modules/sale_price_list:default
details: 
https://hg.tryton.org/modules/sale_price_list?cmd=changeset;node=d5bd02d543d5
description:
        Add salable products menu entry

        This shows the same product list as when selecting product from the 
sale line
        and provide the same contextual options.

        issue8981
        review258651002
diffstat:

 __init__.py                        |   1 +
 product.py                         |  29 +++++++++++++++++++++++++++++
 product.xml                        |  12 ++++++++++++
 tryton.cfg                         |   1 +
 view/product_sale_context_form.xml |   9 +++++++++
 5 files changed, 52 insertions(+), 0 deletions(-)

diffs (90 lines):

diff -r 29a0dbb20154 -r d5bd02d543d5 __init__.py
--- a/__init__.py       Fri Dec 06 17:33:47 2019 +0100
+++ b/__init__.py       Sun Feb 23 13:55:00 2020 +0100
@@ -16,6 +16,7 @@
         SaleLine,
         product.Product,
         product.PriceList,
+        product.SaleContext,
         configuration.Configuration,
         configuration.ConfigurationSalePriceList,
         module='sale_price_list', type_='model')
diff -r 29a0dbb20154 -r d5bd02d543d5 product.py
--- a/product.py        Fri Dec 06 17:33:47 2019 +0100
+++ b/product.py        Sun Feb 23 13:55:00 2020 +0100
@@ -1,5 +1,6 @@
 # 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.model import fields
 from trytond.transaction import Transaction
 from trytond.pool import Pool, PoolMeta
 
@@ -55,3 +56,31 @@
         if self.unit == 'product_sale' and self.product.sale_uom:
             uom = self.product.sale_uom
         return uom
+
+
+class SaleContext(metaclass=PoolMeta):
+    __name__ = 'product.sale.context'
+
+    price_list = fields.Many2One('product.price_list', "Price List")
+
+    @classmethod
+    def default_price_list(cls):
+        pool = Pool()
+        Configuration = pool.get('sale.configuration')
+        config = Configuration(1)
+        if config.sale_price_list:
+            return config.sale_price_list.id
+
+    @fields.depends('customer')
+    def on_change_customer(self):
+        pool = Pool()
+        Configuration = pool.get('sale.configuration')
+        try:
+            super().on_change_customer()
+        except AttributeError:
+            pass
+        if self.customer and self.customer.sale_price_list:
+            self.price_list = self.customer.sale_price_list
+        else:
+            config = Configuration(1)
+            self.price_list = config.sale_price_list
diff -r 29a0dbb20154 -r d5bd02d543d5 product.xml
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/product.xml       Sun Feb 23 13:55:00 2020 +0100
@@ -0,0 +1,12 @@
+<?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.ui.view" id="product_sale_context_view_form">
+            <field name="model">product.sale.context</field>
+            <field name="inherit" ref="sale.product_sale_context_view_form"/>
+            <field name="name">product_sale_context_form</field>
+        </record>
+    </data>
+</tryton>
diff -r 29a0dbb20154 -r d5bd02d543d5 tryton.cfg
--- a/tryton.cfg        Fri Dec 06 17:33:47 2019 +0100
+++ b/tryton.cfg        Sun Feb 23 13:55:00 2020 +0100
@@ -10,3 +10,4 @@
     party.xml
     sale.xml
     configuration.xml
+    product.xml
diff -r 29a0dbb20154 -r d5bd02d543d5 view/product_sale_context_form.xml
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/view/product_sale_context_form.xml        Sun Feb 23 13:55:00 2020 +0100
@@ -0,0 +1,9 @@
+<?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. -->
+<data>
+    <xpath expr="//field[@name='customer']" position="after">
+        <label name="price_list"/>
+        <field name="price_list"/>
+    </xpath>
+</data>

Reply via email to