Cédric Krier pushed to branch branch/default at Tryton / Tryton
Commits:
c383c81b by Cédric Krier at 2023-01-14T17:09:52+01:00
Group only with the fields existing on the shipment
Closes #11998
- - - - -
e56da44a by Cédric Krier at 2023-01-14T17:10:40+01:00
Test shipment grouping with return for #11998
- - - - -
2ddae6bf by Cédric Krier at 2023-01-14T17:11:07+01:00
Use correct name for test scenario of sale shipment grouping
- - - - -
4 changed files:
- modules/sale_shipment_grouping/sale.py
- modules/sale_shipment_grouping/tests/scenario_sale_shipment_grouping.rst
-
modules/sale_shipment_grouping/tests/scenario_sale_shipment_grouping_multiple.rst
- +
modules/sale_shipment_grouping/tests/scenario_sale_shipment_grouping_return.rst
Changes:
=====================================
modules/sale_shipment_grouping/sale.py
=====================================
@@ -37,9 +37,10 @@
('state', 'in', self._shipment_grouping_state),
]
shipment_domain += self._get_grouped_shipment_planned_date(shipment)
- defaults = Shipment.default_get(self._shipment_grouping_fields,
- with_rec_name=False)
- for field in self._shipment_grouping_fields:
+ fields = [
+ f for f in self._shipment_grouping_fields if f in Shipment._fields]
+ defaults = Shipment.default_get(fields, with_rec_name=False)
+ for field in fields:
shipment_domain.append((field, '=',
getattr(shipment, field, defaults.get(field))))
return shipment_domain
=====================================
modules/sale_shipment_grouping/tests/scenario_sale_shipment_grouping.rst
=====================================
@@ -1,6 +1,6 @@
-==============================
-Sale Invoice Grouping Scenario
-==============================
+===============================
+Sale Shipment Grouping Scenario
+===============================
Imports::
=====================================
modules/sale_shipment_grouping/tests/scenario_sale_shipment_grouping_multiple.rst
=====================================
@@ -1,6 +1,6 @@
-=======================================
-Sale Invoice Grouping Multiple Scenario
-=======================================
+========================================
+Sale Shipment Grouping Multiple Scenario
+========================================
Imports::
=====================================
modules/sale_shipment_grouping/tests/scenario_sale_shipment_grouping_return.rst
=====================================
@@ -0,0 +1,77 @@
+======================================
+Sale Shipment Grouping Return Scenario
+======================================
+
+Imports::
+
+ >>> from decimal import Decimal
+ >>> from proteus import Model
+
+ >>> from trytond.tests.tools import activate_modules
+ >>> from trytond.modules.company.tests.tools import (
+ ... create_company, get_company)
+ >>> from trytond.modules.account.tests.tools import (
+ ... create_chart, get_accounts)
+
+Activate modules::
+
+ >>> config = activate_modules('sale_shipment_grouping')
+
+ >>> Party = Model.get('party.party')
+ >>> ProductCategory = Model.get('product.category')
+ >>> ProductTemplate = Model.get('product.template')
+ >>> ProductUom = Model.get('product.uom')
+ >>> Sale = Model.get('sale.sale')
+
+Create company::
+
+ >>> _ = create_company()
+ >>> company = get_company()
+
+Create chart of accounts::
+
+ >>> _ = create_chart(company)
+ >>> accounts = get_accounts(company)
+
+Create parties::
+
+ >>> customer = Party(name='Customer')
+ >>> customer.sale_shipment_grouping_method = 'standard'
+ >>> customer.save()
+
+Create account category::
+
+ >>> account_category = ProductCategory(name="Account Category")
+ >>> account_category.accounting = True
+ >>> account_category.account_expense = accounts['expense']
+ >>> account_category.account_revenue = accounts['revenue']
+ >>> account_category.save()
+
+Create product::
+
+ >>> unit, = ProductUom.find([('name', '=', "Unit")])
+
+ >>> template = ProductTemplate()
+ >>> template.name = "Product"
+ >>> template.default_uom = unit
+ >>> template.type = 'goods'
+ >>> template.salable = True
+ >>> template.list_price = Decimal('10.0000')
+ >>> template.account_category = account_category
+ >>> template.save()
+ >>> product, = template.products
+
+Return a product::
+
+ >>> sale = Sale()
+ >>> sale.party = customer
+ >>> sale.invoice_method = 'order'
+ >>> sale_line = sale.lines.new()
+ >>> sale_line.product = product
+ >>> sale_line.quantity = -1
+ >>> sale.click('quote')
+ >>> sale.click('confirm')
+ >>> sale.state
+ 'processing'
+
+ >>> shipment_return, = sale.shipment_returns
View it on Heptapod:
https://foss.heptapod.net/tryton/tryton/-/compare/e22f31a0163998902145ea47d76ded437e0c7ccf...2ddae6bfbb96cbba9e7367a377ff4533856c59ed
--
View it on Heptapod:
https://foss.heptapod.net/tryton/tryton/-/compare/e22f31a0163998902145ea47d76ded437e0c7ccf...2ddae6bfbb96cbba9e7367a377ff4533856c59ed
You're receiving this email because of your account on foss.heptapod.net.