changeset 97fde7680faa in modules/stock_consignment:default
details:
https://hg.tryton.org/modules/stock_consignment?cmd=changeset&node=97fde7680faa
description:
Add more information on stock move form
issue11768
review439591003
diffstat:
stock.py | 20 +++++++++++++-------
stock.xml | 6 ++++++
view/stock_move_form.xml | 10 ++++++++++
3 files changed, 29 insertions(+), 7 deletions(-)
diffs (73 lines):
diff -r fea57ac2ca9d -r 97fde7680faa stock.py
--- a/stock.py Sun Oct 09 18:55:01 2022 +0200
+++ b/stock.py Sun Oct 09 19:07:16 2022 +0200
@@ -65,7 +65,7 @@
to_save = []
move2line = {}
for move in moves:
- if all(l.origin != move for l in move.invoice_lines):
+ if not move.consignment_invoice_lines:
lines = move.get_invoice_lines_consignment()
if lines:
to_save.extend(lines)
@@ -90,12 +90,11 @@
InvoiceLine = pool.get('account.invoice.line')
lines, to_save = [], []
for move in moves:
- for invoice_line in move.invoice_lines:
- if invoice_line.origin == move:
- lines.append(invoice_line)
- if move.origin == move:
- move.origin = None
- to_save.append(move)
+ for invoice_line in move.consignment_invoice_lines:
+ lines.append(invoice_line)
+ if move.origin == move:
+ move.origin = None
+ to_save.append(move)
if lines:
InvoiceLine.delete(lines)
cls.save(to_save)
@@ -106,6 +105,13 @@
class Move(metaclass=PoolMeta):
__name__ = 'stock.move'
+ consignment_invoice_lines = fields.One2Many(
+ 'account.invoice.line', 'origin', "Consignment Invoice Lines",
+ readonly=True,
+ states={
+ 'invisible': ~Eval('consignment_invoice_lines'),
+ })
+
@fields.depends('state', 'from_location', 'to_location')
def on_change_with_unit_price_required(self, name=None):
required = super().on_change_with_unit_price_required(name)
diff -r fea57ac2ca9d -r 97fde7680faa stock.xml
--- a/stock.xml Sun Oct 09 18:55:01 2022 +0200
+++ b/stock.xml Sun Oct 09 19:07:16 2022 +0200
@@ -8,5 +8,11 @@
<field name="inherit" ref="stock.location_view_form"/>
<field name="name">location_form</field>
</record>
+
+ <record model="ir.ui.view" id="stock_move_view_form">
+ <field name="model">stock.move</field>
+ <field name="inherit" ref="stock.move_view_form"/>
+ <field name="name">stock_move_form</field>
+ </record>
</data>
</tryton>
diff -r fea57ac2ca9d -r 97fde7680faa view/stock_move_form.xml
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/view/stock_move_form.xml Sun Oct 09 19:07:16 2022 +0200
@@ -0,0 +1,10 @@
+<?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="//notebook" position="inside">
+ <page name="consignment_invoice_lines">
+ <field name="consignment_invoice_lines" colspan="4"/>
+ </page>
+ </xpath>
+</data>