Set taxes from the sale line when create a invoice line from shipment cost
Modules activated:
- sale
- sale_shipment_cost
- account_tax_rule_country
Scenario:
- Our company or warehouse is from SPAIN
- Create a new customer and shipment address, to MOROCO.
- Create a sale and select customer to delivery MOROCO. This customer has account tax rule to replace SPAIN to MOROCO taxes.
- Add carrier in the sale.
- Confirn the sale. sale_shipment_cost module create a new sale line, and taxes is from account tax rule ("MOROCO taxes").
- Process the sale. In the shipment, set a shipment cost value and done the shipment.
- Find invoice lines was created: taxes is from the product (SPAIN taxes), when the customer has account tax rule ("MOROCO taxes")..
Conclusion:
New invoice line from sale shipment cost, taxes is from sale line and not default taxes from the product
Example data:
self is a sale.line object:
(Pdb) self.sale.shipment_address.rec_name
'XXXX, TANGER-ASILAH, MA'
(Pdb) self.sale.warehouse.address.rec_name
'XXXX, BARCELONA, ES'
(Pdb) for line in self.sale.party.customer_tax_rule.lines: line.from_country and line.from_country.name, line.to_country and line.to_country.code
('España', 'MA')
('España', 'MA')
('España', 'MA')
(Pdb) invoice_line._get_tax_rule_pattern()
{'date': None, 'from_country': None, 'from_subdivision': None, 'to_country': None, 'to_subdivision': None}
Debug data is from https://github.com/tryton/tryton/blob/0e203ba32a84430b76d01dad5b0a21732cc427a4/modules/sale_shipment_cost/sale.py#L356