changeset 139297ec4faa in modules/stock:default
details: https://hg.tryton.org/modules/stock?cmd=changeset;node=139297ec4faa
description:
Add relate to open inventory lines
issue9563
review290881002
diffstat:
CHANGELOG | 1 +
inventory.py | 29 ++++++++++++++++++++++++++++-
inventory.xml | 21 +++++++++++++++++++++
view/inventory_form.xml | 2 +-
view/inventory_line_list_simple.xml | 9 +++++++++
view/inventory_line_tree.xml | 4 +++-
6 files changed, 63 insertions(+), 3 deletions(-)
diffs (133 lines):
diff -r 7e581e7b9674 -r 139297ec4faa CHANGELOG
--- a/CHANGELOG Sun Sep 27 18:20:34 2020 +0200
+++ b/CHANGELOG Sat Oct 03 23:47:19 2020 +0200
@@ -1,3 +1,4 @@
+* Add relate to open inventory lines
* Use simplified view for moves list on shipments
* Add a relate from product to its moves
* Factorize the cost price of move for cost computation
diff -r 7e581e7b9674 -r 139297ec4faa inventory.py
--- a/inventory.py Sun Sep 27 18:20:34 2020 +0200
+++ b/inventory.py Sat Oct 03 23:47:19 2020 +0200
@@ -49,7 +49,7 @@
('keep', "Keep"),
('empty', "Empty"),
], "Empty Quantity", states=_states, depends=_depends,
- help="How lines without quantity are handled.")
+ help="How lines without a quantity are handled.")
company = fields.Many2One('company.company', 'Company', required=True,
states={
'readonly': (Eval('state') != 'draft') | Eval('lines', [0]),
@@ -322,6 +322,14 @@
},
depends=_depends,
help="The inventory the line belongs to.")
+ inventory_location = fields.Function(
+ fields.Many2One('stock.location', "Location"),
+ 'on_change_with_inventory_location',
+ searcher='search_inventory_location')
+ inventory_date = fields.Function(
+ fields.Date("Date"),
+ 'on_change_with_inventory_date',
+ searcher='search_inventory_date')
inventory_state = fields.Function(
fields.Selection('get_inventory_states', "Inventory State"),
'on_change_with_inventory_state')
@@ -377,6 +385,25 @@
self.uom = self.product.default_uom
self.unit_digits = self.product.default_uom.digits
+ @fields.depends('inventory', '_parent_inventory.location')
+ def on_change_with_inventory_location(self, name=None):
+ if self.inventory and self.inventory.location:
+ return self.inventory.location.id
+
+ @classmethod
+ def search_inventory_location(cls, name, clause):
+ nested = clause[0].lstrip(name)
+ return [('inventory.' + name + nested,) + tuple(clause[1:])]
+
+ @fields.depends('inventory', '_parent_inventory.date')
+ def on_change_with_inventory_date(self, name=None):
+ if self.inventory:
+ return self.inventory.date
+
+ @classmethod
+ def search_inventory_date(cls, name, clause):
+ return [('inventory.date',) + tuple(clause[1:])]
+
@classmethod
def get_inventory_states(cls):
pool = Pool()
diff -r 7e581e7b9674 -r 139297ec4faa inventory.xml
--- a/inventory.xml Sun Sep 27 18:20:34 2020 +0200
+++ b/inventory.xml Sat Oct 03 23:47:19 2020 +0200
@@ -57,8 +57,29 @@
<record model="ir.ui.view" id="inventory_line_view_tree">
<field name="model">stock.inventory.line</field>
<field name="type">tree</field>
+ <field name="priority" eval="10"/>
<field name="name">inventory_line_tree</field>
</record>
+ <record model="ir.ui.view" id="inventory_line_view_list_simple">
+ <field name="model">stock.inventory.line</field>
+ <field name="type">tree</field>
+ <field name="priority" eval="20"/>
+ <field name="name">inventory_line_list_simple</field>
+ </record>
+
+ <record model="ir.action.act_window" id="act_inventory_line_relate">
+ <field name="name">Inventory Lines</field>
+ <field name="res_model">stock.inventory.line</field>
+ <field
+ name="domain"
+ eval="[If(Eval('active_ids', []) == [Eval('active_id')],
('inventory', '=', Eval('active_id')), ('inventory', 'in',
Eval('active_ids')))]"
+ pyson="1"/>
+ </record>
+ <record model="ir.action.keyword"
id="act_inventory_line_relate_keyword1">
+ <field name="keyword">form_relate</field>
+ <field name="model">stock.inventory,-1</field>
+ <field name="action" ref="act_inventory_line_relate"/>
+ </record>
<record model="ir.model.access" id="access_inventory">
<field name="model" search="[('model', '=', 'stock.inventory')]"/>
diff -r 7e581e7b9674 -r 139297ec4faa view/inventory_form.xml
--- a/view/inventory_form.xml Sun Sep 27 18:20:34 2020 +0200
+++ b/view/inventory_form.xml Sat Oct 03 23:47:19 2020 +0200
@@ -15,7 +15,7 @@
<label name="empty_quantity"/>
<field name="empty_quantity"/>
- <field name="lines" colspan="4"/>
+ <field name="lines" colspan="4"
view_ids="stock.inventory_line_view_list_simple"/>
<label name="state"/>
<field name="state"/>
diff -r 7e581e7b9674 -r 139297ec4faa view/inventory_line_list_simple.xml
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/view/inventory_line_list_simple.xml Sat Oct 03 23:47:19 2020 +0200
@@ -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. -->
+<tree editable="1">
+ <field name="product" expand="1"/>
+ <field name="expected_quantity"/>
+ <field name="quantity"/>
+ <field name="uom"/>
+</tree>
diff -r 7e581e7b9674 -r 139297ec4faa view/inventory_line_tree.xml
--- a/view/inventory_line_tree.xml Sun Sep 27 18:20:34 2020 +0200
+++ b/view/inventory_line_tree.xml Sat Oct 03 23:47:19 2020 +0200
@@ -3,7 +3,9 @@
this repository contains the full copyright notices and license terms. -->
<tree editable="1">
<field name="inventory" expand="1"/>
- <field name="product" expand="1"/>
+ <field name="inventory_location" expand="1"/>
+ <field name="inventory_date"/>
+ <field name="product" expand="2"/>
<field name="expected_quantity"/>
<field name="quantity"/>
<field name="uom"/>