changeset 500f680ed531 in modules/purchase:default
details: https://hg.tryton.org/modules/purchase?cmd=changeset;node=500f680ed531
description:
        Remove purchase fields from stock move

        issue8254
        review265251002
diffstat:

 CHANGELOG          |   1 +
 purchase.xml       |   6 -----
 stock.py           |  61 ++---------------------------------------------------
 view/move_form.xml |  25 ----------------------
 4 files changed, 4 insertions(+), 89 deletions(-)

diffs (138 lines):

diff -r 4d722c739d19 -r 500f680ed531 CHANGELOG
--- a/CHANGELOG Thu Apr 11 15:24:46 2019 +0200
+++ b/CHANGELOG Thu Apr 11 19:57:25 2019 +0200
@@ -1,3 +1,4 @@
+* Remove purchase fields from stock move
 * Remove starting wildcard when searching on codes and numbers
 * Allow product supplier to be defined on variants
 
diff -r 4d722c739d19 -r 500f680ed531 purchase.xml
--- a/purchase.xml      Thu Apr 11 15:24:46 2019 +0200
+++ b/purchase.xml      Thu Apr 11 19:57:25 2019 +0200
@@ -532,12 +532,6 @@
             <field name="name">template_tree</field>
         </record>
 
-        <record model="ir.ui.view" id="move_view_form">
-            <field name="model">stock.move</field>
-            <field name="inherit" ref="stock.move_view_form"/>
-            <field name="name">move_form</field>
-        </record>
-
         <record model="ir.action.wizard" id="act_open_supplier">
             <field name="name">Parties associated to Purchases</field>
             <field name="wiz_name">purchase.open_supplier</field>
diff -r 4d722c739d19 -r 500f680ed531 stock.py
--- a/stock.py  Thu Apr 11 15:24:46 2019 +0200
+++ b/stock.py  Thu Apr 11 19:57:25 2019 +0200
@@ -13,8 +13,6 @@
 from trytond.pool import Pool, PoolMeta
 from trytond.transaction import Transaction
 
-from trytond.modules.product import price_digits
-
 __all__ = ['ShipmentIn', 'ShipmentInReturn', 'Move', 'Location']
 
 
@@ -154,35 +152,9 @@
 
 class Move(metaclass=PoolMeta):
     __name__ = 'stock.move'
-    purchase = fields.Function(fields.Many2One('purchase.purchase', 'Purchase',
-            states={
-                'invisible': ~Eval('purchase_visible', False),
-                },
-            depends=['purchase_visible']), 'get_purchase',
-        searcher='search_purchase')
-    purchase_quantity = fields.Function(fields.Float('Purchase Quantity',
-            digits=(16, Eval('unit_digits', 2)),
-            states={
-                'invisible': ~Eval('purchase_visible', False),
-                },
-            depends=['purchase_visible', 'unit_digits']),
-        'get_purchase_fields')
-    purchase_unit = fields.Function(fields.Many2One('product.uom',
-            'Purchase Unit', states={
-                'invisible': ~Eval('purchase_visible', False),
-                }, depends=['purchase_visible']), 'get_purchase_fields')
-    purchase_unit_digits = fields.Function(fields.Integer(
-        'Purchase Unit Digits'), 'get_purchase_fields')
-    purchase_unit_price = fields.Function(fields.Numeric('Purchase Unit Price',
-            digits=price_digits, states={
-                'invisible': ~Eval('purchase_visible', False),
-                }, depends=['purchase_visible']), 'get_purchase_fields')
-    purchase_currency = fields.Function(fields.Many2One('currency.currency',
-            'Purchase Currency', states={
-                'invisible': ~Eval('purchase_visible', False),
-                }, depends=['purchase_visible']), 'get_purchase_fields')
-    purchase_visible = fields.Function(fields.Boolean('Purchase Visible'),
-        'on_change_with_purchase_visible')
+    purchase = fields.Function(
+        fields.Many2One('purchase.purchase', 'Purchase'),
+        'get_purchase', searcher='search_purchase')
     supplier = fields.Function(fields.Many2One('party.party', 'Supplier'),
         'get_supplier', searcher='search_supplier')
     purchase_exception_state = fields.Function(fields.Selection([
@@ -222,33 +194,6 @@
         if self in self.origin.moves_ignored:
             return 'ignored'
 
-    def get_purchase_fields(self, name):
-        PurchaseLine = Pool().get('purchase.line')
-        if isinstance(self.origin, PurchaseLine):
-            if name[9:] == 'currency':
-                return self.origin.purchase.currency.id
-            elif name[9:] in ('quantity', 'unit_digits', 'unit_price'):
-                return getattr(self.origin, name[9:])
-            else:
-                return getattr(self.origin, name[9:]).id
-        else:
-            if name[9:] == 'quantity':
-                return 0.0
-            elif name[9:] == 'unit_digits':
-                return 2
-
-    @fields.depends('from_location', 'to_location')
-    def on_change_with_purchase_visible(self, name=None):
-        if self.from_location:
-            if self.from_location.type == 'supplier':
-                if self.to_location and self.to_location == 'supplier':
-                    return False
-                return True
-        elif self.to_location:
-            if self.to_location.type == 'supplier':
-                return True
-        return False
-
     def get_supplier(self, name):
         PurchaseLine = Pool().get('purchase.line')
         if isinstance(self.origin, PurchaseLine):
diff -r 4d722c739d19 -r 500f680ed531 view/move_form.xml
--- a/view/move_form.xml        Thu Apr 11 15:24:46 2019 +0200
+++ /dev/null   Thu Jan 01 00:00:00 1970 +0000
@@ -1,25 +0,0 @@
-<?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="/form/field[@name='uom']" position="after">
-        <label name="purchase_quantity"/>
-        <field name="purchase_quantity"/>
-        <label name="purchase_unit"/>
-        <field name="purchase_unit"/>
-    </xpath>
-    <xpath expr="/form/field[@name='currency']" position="after">
-        <label name="purchase_unit_price"/>
-        <field name="purchase_unit_price"/>
-        <label name="purchase_currency"/>
-        <field name="purchase_currency"/>
-    </xpath>
-    <xpath expr="/form/field[@name='effective_date']" position="after">
-        <label name="purchase"/>
-        <field name="purchase"/>
-        <newline/>
-    </xpath>
-    <xpath expr="/form/field[@name='unit_digits']" position="after">
-        <field name="purchase_unit_digits" invisible="1" colspan="4"/>
-    </xpath>
-</data>

Reply via email to