Limit links between invoice line and stock moves
issue9143 review274981002
This commit is contained in:
1 parent
d8cb03642e
commit
4e1ce75819
3 files changed
+57
-7
No files matched your search
@@ -1,3 +1,5 @@
|
||||
* Limit links between invoice line and stock moves
|
||||
|
||||
Version 5.4.0 - 2019-11-04
|
||||
* Bug fixes (see mercurial logs for details)
|
||||
|
||||
|
||||
+22
-5
@@ -2,7 +2,7 @@
|
||||
# this repository contains the full copyright notices and license terms.
|
||||
from trytond.model import ModelSQL, fields
|
||||
from trytond.pool import Pool, PoolMeta
|
||||
from trytond.pyson import Eval
|
||||
from trytond.pyson import Eval, If
|
||||
|
||||
|
||||
class InvoiceLineStockMove(ModelSQL):
|
||||
@@ -17,12 +17,29 @@ class InvoiceLineStockMove(ModelSQL):
|
||||
|
||||
class InvoiceLine(metaclass=PoolMeta):
|
||||
__name__ = 'account.invoice.line'
|
||||
stock_moves = fields.Many2Many('account.invoice.line-stock.move',
|
||||
'invoice_line', 'stock_move', 'Stock Moves',
|
||||
stock_moves = fields.Many2Many(
|
||||
'account.invoice.line-stock.move', 'invoice_line', 'stock_move',
|
||||
"Stock Moves",
|
||||
domain=[
|
||||
('product.default_uom_category',
|
||||
'=', Eval('product_uom_category', -1)),
|
||||
If((Eval('_parent_invoice', {}).get('type') == 'out')
|
||||
| (Eval('invoice_type') == 'out'),
|
||||
['OR',
|
||||
('to_location.type', '=', 'customer'),
|
||||
('from_location.type', '=', 'customer'),
|
||||
],
|
||||
['OR',
|
||||
('from_location.type', '=', 'supplier'),
|
||||
('to_location.type', '=', 'supplier'),
|
||||
]),
|
||||
],
|
||||
states={
|
||||
'invisible': Eval('type') != 'line',
|
||||
'invisible': (
|
||||
(Eval('type') != 'line')
|
||||
| ~Eval('product')),
|
||||
},
|
||||
depends=['type'])
|
||||
depends=['type', 'product_uom_category', 'invoice', 'invoice_type'])
|
||||
|
||||
@property
|
||||
def moved_quantity(self):
|
||||
|
||||
@@ -3,12 +3,43 @@
|
||||
from trytond.model import fields
|
||||
from trytond.pool import Pool, PoolMeta
|
||||
from trytond.transaction import Transaction
|
||||
from trytond.pyson import Eval
|
||||
|
||||
|
||||
class Move(metaclass=PoolMeta):
|
||||
__name__ = 'stock.move'
|
||||
invoice_lines = fields.Many2Many('account.invoice.line-stock.move',
|
||||
'stock_move', 'invoice_line', 'Invoice Lines')
|
||||
invoice_lines = fields.Many2Many(
|
||||
'account.invoice.line-stock.move', 'stock_move', 'invoice_line',
|
||||
"Invoice Lines",
|
||||
domain=[
|
||||
('product.default_uom_category',
|
||||
'=', Eval('product_uom_category', -1)),
|
||||
['OR',
|
||||
('invoice.type', 'in', Eval('invoice_types', [])),
|
||||
('invoice_type', 'in', Eval('invoice_types', [])),
|
||||
],
|
||||
],
|
||||
depends=['product_uom_category', 'invoice_types'])
|
||||
invoice_types = fields.Function(
|
||||
fields.MultiSelection('get_invoice_types', "Invoice Types"),
|
||||
'on_change_with_invoice_types')
|
||||
|
||||
@classmethod
|
||||
def get_invoice_types(cls):
|
||||
pool = Pool()
|
||||
Invoice = pool.get('account.invoice')
|
||||
return Invoice.fields_get(['type'])['type']['selection'] + [(None, '')]
|
||||
|
||||
@fields.depends('from_location', 'to_location')
|
||||
def on_change_with_invoice_types(self, name=None):
|
||||
types = set()
|
||||
for location in [self.from_location, self.to_location]:
|
||||
if location:
|
||||
if location.type == 'customer':
|
||||
types.add('out')
|
||||
elif location.type == 'supplier':
|
||||
types.add('in')
|
||||
return list(types)
|
||||
|
||||
@property
|
||||
def invoiced_quantity(self):
|
||||
|
||||
Reference in new issue
Block a user