Add CMR text fields on party.

This commit refs #13561
This commit is contained in:
Francisco jose 2020-06-05 17:34:25 +02:00 committed by Sergio Morillo
parent 86700e79d3
commit 03c3bee171
9 changed files with 559 additions and 480 deletions

View File

@ -8,6 +8,7 @@ from .stock import (Move, ShipmentOut, ShipmentInternal, LoadShipment,
ShipmentOutReturn, ShipmentInReturn)
from .purchase import Purchase
from .carrier import Carrier
from .party import Party
def register():
@ -26,6 +27,7 @@ def register():
ShipmentInReturn,
ConfigurationSequence,
sale.Sale,
Party,
module='carrier_load', type_='model')
Pool.register(
sale.CostType,

938
cmr.fodt

File diff suppressed because it is too large Load Diff

16
load.py
View File

@ -854,6 +854,8 @@ class LoadOrder(Workflow, ModelView, ModelSQL, IncotermDocumentMixin):
def get_cmr_instructions(self, name=None):
if self.edit_cmr_instructions:
return self.cmr_instructions_store
if self.party:
return self.party.cmr_instructions_used
Conf = Pool().get('carrier.configuration')
return Conf(1).cmr_instructions
@ -1501,20 +1503,6 @@ class CMR(NoteMixin, CompanyReport):
return value or []
class CMRInstructionsMixin(object):
def _update_cmr_instructions(self, orders, instructions):
pool = Pool()
Conf = pool.get('carrier.configuration')
Order = pool.get('carrier.load.order')
conf = Conf(1)
if instructions != conf.cmr_instructions:
Order.write(orders, {
'edit_cmr_instructions': True,
'cmr_instructions': self.ask_party.cmr_instructions
})
class RoadTransportNote(NoteMixin, CompanyReport):
"""Road transport note"""
__name__ = 'carrier.load.order.road_note'

View File

@ -90,6 +90,14 @@ msgctxt "field:carrier.configuration,trailer_required:"
msgid "Trailer required"
msgstr "Remolque obligatorio"
msgctxt "field:party.party,carrier_cmr_comment:"
msgid "Carrier cmr comment"
msgstr "Comentario transportista en CMR"
msgctxt "field:party.party,cmr_instructions:"
msgid "CMR instructions"
msgstr "Instrucciones CMR"
msgctxt "field:carrier.load,carrier:"
msgid "Carrier"
msgstr "Transportista"
@ -618,6 +626,10 @@ msgctxt "selection:carrier.load.order,state:"
msgid "Waiting"
msgstr "En espera"
msgctxt "view:party.party:"
msgid "Carrier"
msgstr "Transporte"
msgctxt "view:carrier.load.order.line:"
msgid "Load order line"
msgstr "Línea orden de carga"

25
party.py Normal file
View File

@ -0,0 +1,25 @@
# The COPYRIGHT file at the top level of this repository contains the full
# copyright notices and license terms.
from trytond.pool import PoolMeta, Pool
from trytond.model import fields
from trytond.pyson import Eval
class Party(metaclass=PoolMeta):
__name__ = 'party.party'
carrier_cmr_comment = fields.Text('Carrier cmr comment',
states={
'readonly': ~Eval('active')
}, depends=['active'])
cmr_instructions = fields.Text('CMR instructions',
states={
'readonly': ~Eval('active')
}, depends=['active'])
@property
def cmr_instructions_used(self):
if self.cmr_instructions:
return self.cmr_instructions
Conf = Pool().get('carrier.configuration')
return Conf(1).cmr_instructions

12
party.xml Normal file
View File

@ -0,0 +1,12 @@
<?xml version="1.0"?>
<!-- The COPYRIGHT file at the top level of this repository contains the full
copyright notices and license terms. -->
<tryton>
<data>
<record model="ir.ui.view" id="party_view_form">
<field name="model">party.party</field>
<field name="inherit" ref="party.party_view_form"/>
<field name="name">party_form</field>
</record>
</data>
</tryton>

View File

@ -238,3 +238,21 @@ Check reports::
'odt'
>>> name
'Road transport note'
Check cmr instructions::
>>> Order = Model.get('carrier.load.order')
>>> Conf = Model.get('carrier.configuration')
>>> carrier_conf = Conf(1)
>>> carrier_conf.cmr_instructions = 'global CMR instructions'
>>> carrier_conf.save()
>>> order = Order(load=load)
>>> order.save()
>>> order.cmr_instructions
'global CMR instructions'
>>> order.party = customer
>>> order.save()
>>> customer.cmr_instructions = 'Party instructions'
>>> customer.save()
>>> order.cmr_instructions
'Party instructions'

View File

@ -19,4 +19,5 @@ xml:
load.xml
configuration.xml
stock.xml
sale.xml
sale.xml
party.xml

13
view/party_form.xml Normal file
View File

@ -0,0 +1,13 @@
<?xml version="1.0"?>
<!-- The COPYRIGHT file at the top level of this repository contains the full
copyright notices and license terms. -->
<data>
<xpath expr="/form/notebook" position="inside">
<page string="Carrier" id="carrier">
<label name="carrier_cmr_comment" colspan="2" xalign="0" />
<label name="cmr_instructions" colspan="2" xalign="0" />
<field name="carrier_cmr_comment" colspan="2" />
<field name="cmr_instructions" colspan="2" />
</page>
</xpath>
</data>