New wizard for sale.sale to print cmr or road note.
This commit refs #23907
This commit is contained in:
parent
1af9ea17dd
commit
453ff963e6
|
@ -66,4 +66,5 @@ def register():
|
|||
load.DoLoadOrder,
|
||||
load.CarrierDefine,
|
||||
load.PrintCarrierLoadPurchase,
|
||||
sale.PrintCarrierNote,
|
||||
module='carrier_load', type_='wizard')
|
||||
|
|
18
load.py
18
load.py
|
@ -1271,6 +1271,24 @@ class LoadOrder(Workflow, ModelView, ModelSQL, IncotermDocumentMixin,
|
|||
('//page[@id="incoterms"]', 'states', {
|
||||
'invisible': ~Eval('party')})]
|
||||
|
||||
def get_carrier_report(self):
|
||||
from_country = (self.warehouse and self.warehouse.address
|
||||
and self.warehouse.address.country)
|
||||
if self.type == 'out':
|
||||
to_country = (self.sale and self.sale.shipment_address
|
||||
and self.sale.shipment_address.country)
|
||||
elif self.type == 'internal':
|
||||
to_country = (self.to_location and self.to_location.address
|
||||
and self.to_location.address.country)
|
||||
elif self.type == 'in_return':
|
||||
to_address = self.party.address_get(type='delivery')
|
||||
to_country = to_address and to_address.country
|
||||
if (not from_country
|
||||
or not to_country
|
||||
or from_country != to_country):
|
||||
return 'cmr'
|
||||
return 'road_note'
|
||||
|
||||
|
||||
class LoadOrderIncoterm(ModelView, ModelSQL, IncotermMixin):
|
||||
"""Load order Incoterm"""
|
||||
|
|
|
@ -1445,4 +1445,8 @@ msgstr "Compra"
|
|||
|
||||
msgctxt "model:ir.action,name:report_carrier_load_purchase"
|
||||
msgid "Carrier load purchase"
|
||||
msgstr "Compra transporte de carga"
|
||||
msgstr "Compra transporte de carga"
|
||||
|
||||
msgctxt "model:ir.action,name:wizard_sale_print_carrier_note"
|
||||
msgid "Carrier note"
|
||||
msgstr "Documento de transporte"
|
45
sale.py
45
sale.py
|
@ -7,6 +7,7 @@ from trytond.pyson import Eval
|
|||
from trytond.transaction import Transaction
|
||||
from trytond.exceptions import UserError
|
||||
from trytond.i18n import gettext
|
||||
from trytond.wizard import Wizard, StateTransition, StateReport
|
||||
|
||||
|
||||
class Sale(metaclass=PoolMeta):
|
||||
|
@ -158,3 +159,47 @@ class SaleReport(metaclass=PoolMeta):
|
|||
with Transaction().set_context(_check_access=False):
|
||||
# allow to print without sale group
|
||||
return super().execute(ids, data)
|
||||
|
||||
|
||||
class PrintCarrierNote(Wizard):
|
||||
"""Print Sale Carrier note"""
|
||||
__name__ = 'sale.print_carrier_note'
|
||||
|
||||
start = StateTransition()
|
||||
print_ = StateTransition()
|
||||
print_cmr = StateReport('carrier.load.order.cmr')
|
||||
print_road_note = StateReport('carrier.load.order.road_note')
|
||||
|
||||
def transition_start(self):
|
||||
Order = Pool().get('carrier.load.order')
|
||||
|
||||
self.to_print = {}
|
||||
for sale in self.records:
|
||||
if sale.origin and isinstance(sale.origin, Order):
|
||||
self.to_print.setdefault(sale.origin.get_carrier_report(),
|
||||
[]).append(sale.origin.id)
|
||||
return 'print_'
|
||||
|
||||
def transition_print_(self):
|
||||
if self.to_print.get('cmr', []):
|
||||
return 'print_cmr'
|
||||
elif self.to_print.get('road_note', []):
|
||||
return 'print_road_note'
|
||||
else:
|
||||
return 'end'
|
||||
|
||||
def do_print_cmr(self, action):
|
||||
ids = self.to_print.pop('cmr')
|
||||
data = {'ids': ids}
|
||||
return action, data
|
||||
|
||||
def transition_print_cmr(self):
|
||||
return 'print_'
|
||||
|
||||
def do_print_road_note(self, action):
|
||||
ids = self.to_print.pop('road_note')
|
||||
data = {'ids': ids}
|
||||
return action, data
|
||||
|
||||
def transition_print_road_note(self):
|
||||
return 'print_'
|
||||
|
|
13
sale.xml
13
sale.xml
|
@ -2,6 +2,19 @@
|
|||
<!-- The COPYRIGHT file at the top level of this repository contains the full
|
||||
copyright notices and license terms. -->
|
||||
<tryton>
|
||||
<data>
|
||||
<!-- Wizard print carrier note -->
|
||||
<record model="ir.action.wizard" id="wizard_sale_print_carrier_note">
|
||||
<field name="name">Carrier note</field>
|
||||
<field name="wiz_name">sale.print_carrier_note</field>
|
||||
<field name="model">sale.sale</field>
|
||||
</record>
|
||||
<record model="ir.action.keyword" id="act_sale_print_carrier_note_keyword">
|
||||
<field name="keyword">form_print</field>
|
||||
<field name="model">sale.sale,-1</field>
|
||||
<field name="action" ref="wizard_sale_print_carrier_note"/>
|
||||
</record>
|
||||
</data>
|
||||
<data depends="sale_cost">
|
||||
<record model="ir.ui.view" id="cost_type_view_form">
|
||||
<field name="model">sale.cost.type</field>
|
||||
|
|
Loading…
Reference in New Issue