Move tax rule pattern from stock move to invoice line
Since fea57ac2ca9d the taxes for consignment invoice lines are computed by the invoice line and no more by the stock move. Closes #13432
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
|
||||
from trytond.pool import Pool
|
||||
|
||||
from . import account, purchase, sale, stock
|
||||
from . import account, purchase, sale
|
||||
|
||||
|
||||
def register():
|
||||
@@ -26,7 +26,3 @@ def register():
|
||||
purchase.Line,
|
||||
module='account_tax_rule_country', type_='model',
|
||||
depends=['purchase'])
|
||||
Pool.register(
|
||||
stock.Move,
|
||||
module='account_tax_rule_country', type_='model',
|
||||
depends=['stock'])
|
||||
|
||||
@@ -114,6 +114,12 @@ class InvoiceLine(metaclass=PoolMeta):
|
||||
PurchaseLine = pool.get('purchase.line')
|
||||
except KeyError:
|
||||
PurchaseLine = None
|
||||
try:
|
||||
Move = pool.get('stock.move')
|
||||
ShipmentOut = pool.get('stock.shipment.out')
|
||||
ShipmentOutReturn = pool.get('stock.shipment.out.return')
|
||||
except KeyError:
|
||||
Move = ShipmentOut = ShipmentOutReturn = None
|
||||
|
||||
pattern = super(InvoiceLine, self)._get_tax_rule_pattern()
|
||||
|
||||
@@ -138,6 +144,28 @@ class InvoiceLine(metaclass=PoolMeta):
|
||||
if warehouse and warehouse.address:
|
||||
to_country = warehouse.address.country
|
||||
to_subdivision = warehouse.address.subdivision
|
||||
elif (Move
|
||||
and isinstance(self.origin, Move)
|
||||
and self.origin.id >= 0):
|
||||
move = self.origin
|
||||
if move.from_location.warehouse:
|
||||
warehouse_address = move.from_location.warehouse.address
|
||||
if warehouse_address:
|
||||
from_country = warehouse_address.country
|
||||
from_subdivision = warehouse_address.subdivision
|
||||
elif isinstance(move.origin, ShipmentOutReturn):
|
||||
delivery_address = move.origin.delivery_address
|
||||
from_country = delivery_address.country
|
||||
from_subdivision = delivery_address.subdivision
|
||||
if move.to_location.warehouse:
|
||||
warehouse_address = move.to_location.warehouse.address
|
||||
if warehouse_address:
|
||||
to_country = warehouse_address.country
|
||||
to_subdivision = warehouse_address.subdivision
|
||||
elif isinstance(move.origin, ShipmentOut):
|
||||
delivery_address = move.origin.delivery_address
|
||||
to_country = delivery_address.country
|
||||
to_subdivision = delivery_address.subdivision
|
||||
|
||||
pattern['from_country'] = from_country.id if from_country else None
|
||||
pattern['from_subdivision'] = (
|
||||
|
||||
@@ -1,43 +0,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.
|
||||
|
||||
from trytond.pool import Pool, PoolMeta
|
||||
|
||||
|
||||
class Move(metaclass=PoolMeta):
|
||||
__name__ = 'stock.move'
|
||||
|
||||
def _get_tax_rule_pattern(self):
|
||||
pool = Pool()
|
||||
ShipmentOut = pool.get('stock.shipment.out')
|
||||
ShipmentOutReturn = pool.get('stock.shipment.out.return')
|
||||
|
||||
pattern = super(Move, self)._get_tax_rule_pattern()
|
||||
|
||||
from_country = from_subdivision = to_country = to_subdivision = None
|
||||
if self.from_location.warehouse:
|
||||
warehouse_address = self.from_location.warehouse.address
|
||||
if warehouse_address:
|
||||
from_country = warehouse_address.country
|
||||
from_subdivision = warehouse_address.subdivision
|
||||
elif isinstance(self.origin, ShipmentOutReturn):
|
||||
delivery_address = self.origin.delivery_address
|
||||
from_country = delivery_address.country
|
||||
from_subdivision = delivery_address.subdivision
|
||||
if self.to_location.warehouse:
|
||||
warehouse_address = self.to_location.warehouse.address
|
||||
if warehouse_address:
|
||||
to_country = warehouse_address.country
|
||||
to_subdivision = warehouse_address.subdivision
|
||||
elif isinstance(self.origin, ShipmentOut):
|
||||
delivery_address = self.origin.delivery_address
|
||||
to_country = delivery_address.country
|
||||
to_subdivision = delivery_address.subdivision
|
||||
|
||||
pattern['from_country'] = from_country.id if from_country else None
|
||||
pattern['from_subdivision'] = (
|
||||
from_subdivision.id if from_subdivision else None)
|
||||
pattern['to_country'] = to_country.id if to_country else None
|
||||
pattern['to_subdivision'] = (
|
||||
to_subdivision.id if to_subdivision else None)
|
||||
return pattern
|
||||
@@ -7,6 +7,6 @@ extras_depend:
|
||||
account_invoice
|
||||
purchase
|
||||
sale
|
||||
stock_consignment
|
||||
stock
|
||||
xml:
|
||||
account.xml
|
||||
|
||||
Reference in New Issue
Block a user