KeyError when processing a sale with modules sale_shipment_cost and sale_shipment_grouping installed.
Tested in default.
- Install the modules sale_shipment_cost and sale_shipment_grouping and its dependencies.
- Create a party customer, and a party carrier
- Create a goods product with the salable check
- Create a service product to the carrier
- Create a carrier with the party carrier created in point 2 and the product from the point 4. With the carrier cost method "Product Price" and with the allocation method "By Cost"
- In the sale configuration, use:
- Sale Invoice Method: On Shipment Send
- Sale Shipment Method: On Order Processed
- Sale Shipment Cost Method: On Shipment
- Sale Shipment Grouping Method: Standard
- Create a sale where:
- The party is the party customer
- With the carrier from the point 5
- The invoice method, shipment method and shipment cost method must be the same that we have configured (in the "Other Info" party)
- Create a line with the salable product from the point 3 where we have negative quantity.
- When we try to process the sale, the KeyError appears:
Traceback (most recent call last):
File "/home/juanjo/Projectes/tryton_core/trytond/trytond/protocols/wrappers.py", line 178, in wrapper
return func(request, pool, *args, **kwargs)
File "/home/juanjo/Projectes/tryton_core/trytond/trytond/protocols/dispatcher.py", line 200, in _dispatch
result = rpc.result(meth(*c_args, **c_kwargs))
File "/home/juanjo/Projectes/tryton_core/trytond/trytond/model/modelview.py", line 697, in wrapper
return func(cls, records, *args, **kwargs)
File "/home/juanjo/Projectes/tryton_core/trytond/trytond/modules/sale_shipment_cost/sale.py", line 230, in process
super().process(sales)
File "/home/juanjo/Projectes/tryton_core/trytond/trytond/model/modelview.py", line 697, in wrapper
return func(cls, records, *args, **kwargs)
File "/home/juanjo/Projectes/tryton_core/trytond/trytond/modules/sale/sale.py", line 1013, in process
cls._process_shipment(sales)
File "/home/juanjo/Projectes/tryton_core/trytond/trytond/modules/sale_shipment_grouping/sale.py", line 72, in _process_shipment
super()._process_shipment([sale])
File "/home/juanjo/Projectes/tryton_core/trytond/trytond/modules/sale/sale.py", line 1044, in _process_shipment
shipments = sale.create_shipment('return')
File "/home/juanjo/Projectes/tryton_core/trytond/trytond/modules/sale/sale.py", line 922, in create_shipment
shipment = self._get_shipment_sale(Shipment, key)
File "/home/juanjo/Projectes/tryton_core/trytond/trytond/modules/sale_shipment_cost/sale.py", line 323, in _get_shipment_sale
shipment = super()._get_shipment_sale(Shipment, key)
File "/home/juanjo/Projectes/tryton_core/trytond/trytond/modules/sale_shipment_grouping/sale.py", line 59, in _get_shipment_sale
domain = self._get_grouped_shipment_domain(shipment)
File "/home/juanjo/Projectes/tryton_core/trytond/trytond/modules/sale_shipment_grouping/sale.py", line 41, in _get_grouped_shipment_domain
defaults = Shipment.default_get(self._shipment_grouping_fields,
File "/home/juanjo/Projectes/tryton_core/trytond/trytond/model/model.py", line 150, in default_get
field = cls._fields[field_name]
KeyError: 'delivery_address'
The error appears because the "delivery_address" field it is not on the "shipment.out.return" model (https://foss.heptapod.net/tryton/tryton/-/blob/branch/default/modules/sale_shipment_grouping/sale.py#L21-23).
I think the same problem will appear with the "cost_method" field in the sale_shipment_cost module (https://foss.heptapod.net/tryton/tryton/-/blob/branch/default/modules/sale_shipment_cost/sale.py#L308-310).