Add CMR template model.

This commit refs #13561
This commit is contained in:
Sergio Morillo 2020-06-11 19:56:08 +02:00
parent 03c3bee171
commit fc0e58b9b5
18 changed files with 1194 additions and 613 deletions

View File

@ -9,10 +9,13 @@ from .stock import (Move, ShipmentOut, ShipmentInternal, LoadShipment,
from .purchase import Purchase
from .carrier import Carrier
from .party import Party
from . import cmr
def register():
Pool.register(
cmr.CMRTemplate,
cmr.CMRTemplateLine,
Configuration,
Carrier,
load.Load,
@ -39,7 +42,7 @@ def register():
depends=['sale_cost'])
Pool.register(
load.LoadSheet,
load.CMR,
cmr.CMR,
load.RoadTransportNote,
module='carrier_load', type_='report')
Pool.register(

126
cmr.fodt
View File

@ -1,24 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<office:document xmlns:officeooo="http://openoffice.org/2009/office" xmlns:css3t="http://www.w3.org/TR/css3-text/" xmlns:grddl="http://www.w3.org/2003/g/data-view#" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0" xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" xmlns:rpt="http://openoffice.org/2005/report" xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0" xmlns:config="urn:oasis:names:tc:opendocument:xmlns:config:1.0" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" xmlns:of="urn:oasis:names:tc:opendocument:xmlns:of:1.2" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:ooo="http://openoffice.org/2004/office" xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0" xmlns:formx="urn:openoffice:names:experimental:ooxml-odf-interop:xmlns:form:1.0" xmlns:calcext="urn:org:documentfoundation:names:experimental:calc:xmlns:calcext:1.0" xmlns:drawooo="http://openoffice.org/2010/draw" xmlns:field="urn:openoffice:names:experimental:ooo-ms-interop:xmlns:field:1.0" xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0" xmlns:ooow="http://openoffice.org/2004/writer" xmlns:oooc="http://openoffice.org/2004/calc" xmlns:tableooo="http://openoffice.org/2009/table" xmlns:loext="urn:org:documentfoundation:names:experimental:office:xmlns:loext:1.0" xmlns:math="http://www.w3.org/1998/Math/MathML" xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0" xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0" xmlns:dom="http://www.w3.org/2001/xml-events" xmlns:xforms="http://www.w3.org/2002/xforms" office:version="1.2" office:mimetype="application/vnd.oasis.opendocument.text">
<office:meta><meta:creation-date>2015-11-27T11:30:47.981880000</meta:creation-date><dc:date>2020-06-05T19:49:07.309199835</dc:date><meta:editing-duration>PT11H7M6S</meta:editing-duration><meta:editing-cycles>355</meta:editing-cycles><meta:generator>LibreOffice/6.4.4.2$Linux_X86_64 LibreOffice_project/40$Build-2</meta:generator><meta:document-statistic meta:table-count="7" meta:image-count="0" meta:object-count="0" meta:page-count="3" meta:paragraph-count="230" meta:word-count="778" meta:character-count="6348" meta:non-whitespace-character-count="5774"/></office:meta>
<office:meta><meta:creation-date>2015-11-27T11:30:47.981880000</meta:creation-date><dc:date>2020-06-11T19:50:56.189132063</dc:date><meta:editing-duration>PT11H10M8S</meta:editing-duration><meta:editing-cycles>360</meta:editing-cycles><meta:generator>LibreOffice/6.4.4.2$Linux_X86_64 LibreOffice_project/40$Build-2</meta:generator><meta:document-statistic meta:table-count="7" meta:image-count="0" meta:object-count="0" meta:page-count="3" meta:paragraph-count="232" meta:word-count="798" meta:character-count="6663" meta:non-whitespace-character-count="6072"/></office:meta>
<office:settings>
<config:config-item-set config:name="ooo:view-settings">
<config:config-item config:name="ViewAreaTop" config:type="long">38326</config:config-item>
<config:config-item config:name="ViewAreaTop" config:type="long">74064</config:config-item>
<config:config-item config:name="ViewAreaLeft" config:type="long">0</config:config-item>
<config:config-item config:name="ViewAreaWidth" config:type="long">27063</config:config-item>
<config:config-item config:name="ViewAreaHeight" config:type="long">11673</config:config-item>
<config:config-item config:name="ViewAreaHeight" config:type="long">12247</config:config-item>
<config:config-item config:name="ShowRedlineChanges" config:type="boolean">true</config:config-item>
<config:config-item config:name="InBrowseMode" config:type="boolean">false</config:config-item>
<config:config-item-map-indexed config:name="Views">
<config:config-item-map-entry>
<config:config-item config:name="ViewId" config:type="string">view2</config:config-item>
<config:config-item config:name="ViewLeft" config:type="long">13363</config:config-item>
<config:config-item config:name="ViewTop" config:type="long">45697</config:config-item>
<config:config-item config:name="ViewLeft" config:type="long">4030</config:config-item>
<config:config-item config:name="ViewTop" config:type="long">76121</config:config-item>
<config:config-item config:name="VisibleLeft" config:type="long">0</config:config-item>
<config:config-item config:name="VisibleTop" config:type="long">38326</config:config-item>
<config:config-item config:name="VisibleTop" config:type="long">74064</config:config-item>
<config:config-item config:name="VisibleRight" config:type="long">27062</config:config-item>
<config:config-item config:name="VisibleBottom" config:type="long">49997</config:config-item>
<config:config-item config:name="VisibleBottom" config:type="long">86309</config:config-item>
<config:config-item config:name="ZoomType" config:type="short">0</config:config-item>
<config:config-item config:name="ViewLayoutColumns" config:type="short">0</config:config-item>
<config:config-item config:name="ViewLayoutBookMode" config:type="boolean">false</config:config-item>
@ -79,7 +79,7 @@
<config:config-item config:name="AddParaTableSpacing" config:type="boolean">true</config:config-item>
<config:config-item config:name="PrinterSetup" config:type="base64Binary"/>
<config:config-item config:name="AddParaTableSpacingAtStart" config:type="boolean">true</config:config-item>
<config:config-item config:name="Rsid" config:type="int">22141836</config:config-item>
<config:config-item config:name="Rsid" config:type="int">22231884</config:config-item>
<config:config-item config:name="EmbeddedDatabaseName" config:type="string"/>
<config:config-item config:name="FieldAutoUpdate" config:type="boolean">true</config:config-item>
<config:config-item config:name="OutlineLevelYieldsNumbering" config:type="boolean">false</config:config-item>
@ -141,7 +141,7 @@
<office:styles>
<style:default-style style:family="graphic">
<style:graphic-properties svg:stroke-color="#3465a4" draw:fill-color="#729fcf" fo:wrap-option="no-wrap" draw:shadow-offset-x="0.3cm" draw:shadow-offset-y="0.3cm" draw:start-line-spacing-horizontal="0.283cm" draw:start-line-spacing-vertical="0.283cm" draw:end-line-spacing-horizontal="0.283cm" draw:end-line-spacing-vertical="0.283cm" style:flow-with-text="false"/>
<style:paragraph-properties style:text-autospace="ideograph-alpha" style:line-break="strict" style:writing-mode="lr-tb" style:font-independent-line-spacing="false">
<style:paragraph-properties style:text-autospace="ideograph-alpha" style:line-break="strict" style:font-independent-line-spacing="false">
<style:tab-stops/>
</style:paragraph-properties>
<style:text-properties style:use-window-font-color="true" style:font-name="Liberation Serif" fo:font-size="12pt" fo:language="es" fo:country="ES" style:letter-kerning="true" style:font-name-asian="SimSun" style:font-size-asian="10.5pt" style:language-asian="zh" style:country-asian="CN" style:font-name-complex="Lucida Sans" style:font-size-complex="12pt" style:language-complex="hi" style:country-complex="IN"/>
@ -234,6 +234,7 @@
</style:tab-stops>
</style:paragraph-properties>
</style:style>
<style:style style:name="Frame_20_contents" style:display-name="Frame contents" style:family="paragraph" style:parent-style-name="Standard" style:class="extra"/>
<style:style style:name="Placeholder" style:family="text">
<style:text-properties fo:font-variant="small-caps" fo:color="#008080" style:text-underline-style="dotted" style:text-underline-width="auto" style:text-underline-color="font-color"/>
</style:style>
@ -887,9 +888,6 @@
<style:style style:name="Table10.27" style:family="table-row">
<style:table-row-properties style:min-row-height="0.496cm" fo:keep-together="always"/>
</style:style>
<style:style style:name="Table10.B27" style:family="table-cell">
<style:table-cell-properties style:vertical-align="middle" fo:padding="0.097cm" fo:border-left="none" fo:border-right="none" fo:border-top="0.05pt solid #000000" fo:border-bottom="none"/>
</style:style>
<style:style style:name="Table10.N27" style:family="table-cell">
<style:table-cell-properties style:vertical-align="middle" fo:padding="0.097cm" fo:border-left="1.5pt solid #000000" fo:border-right="none" fo:border-top="1.5pt solid #000000" fo:border-bottom="none"/>
</style:style>
@ -902,9 +900,6 @@
<style:style style:name="Table10.28" style:family="table-row">
<style:table-row-properties style:min-row-height="1.196cm" fo:keep-together="always"/>
</style:style>
<style:style style:name="Table10.B28" style:family="table-cell">
<style:table-cell-properties style:vertical-align="middle" fo:padding="0.097cm" fo:border="none"/>
</style:style>
<style:style style:name="Table10.N28" style:family="table-cell">
<style:table-cell-properties style:vertical-align="middle" fo:padding="0.097cm" fo:border-left="1.5pt solid #000000" fo:border-right="none" fo:border-top="none" fo:border-bottom="1.5pt solid #000000"/>
</style:style>
@ -1367,21 +1362,57 @@
<style:style style:name="P79" style:family="paragraph" style:parent-style-name="Untitled1">
<style:text-properties officeooo:paragraph-rsid="0148abee"/>
</style:style>
<style:style style:name="P80" style:family="paragraph" style:parent-style-name="Standard" style:master-page-name="Standard">
<style:style style:name="P80" style:family="paragraph" style:parent-style-name="Frame_20_contents">
<style:text-properties fo:font-size="9pt" style:font-size-asian="7.84999990463257pt" style:font-size-complex="9pt"/>
</style:style>
<style:style style:name="P81" style:family="paragraph" style:parent-style-name="Standard" style:master-page-name="Standard">
<style:paragraph-properties fo:margin-left="0cm" fo:margin-right="0cm" fo:text-indent="0cm" style:auto-text-indent="false" style:page-number="auto"/>
<style:text-properties style:use-window-font-color="true" fo:font-size="6pt" fo:font-weight="bold" officeooo:rsid="0041e7cd" officeooo:paragraph-rsid="011680d0" fo:background-color="#eeeeee" style:font-size-asian="6pt" style:font-weight-asian="bold" style:font-size-complex="6pt" style:font-weight-complex="bold"/>
</style:style>
<style:style style:name="P81" style:family="paragraph" style:parent-style-name="Standard" style:master-page-name="Standard">
<style:style style:name="P82" style:family="paragraph" style:parent-style-name="Standard" style:master-page-name="Standard">
<style:paragraph-properties fo:margin-left="0cm" fo:margin-right="0cm" fo:text-align="start" style:justify-single-word="false" fo:text-indent="0cm" style:auto-text-indent="false" style:page-number="auto" fo:break-before="auto" fo:break-after="auto" style:shadow="none">
<style:tab-stops/>
</style:paragraph-properties>
<style:text-properties style:use-window-font-color="true" fo:font-size="6pt" fo:font-weight="bold" officeooo:rsid="004be37f" officeooo:paragraph-rsid="010b2310" fo:background-color="transparent" style:font-size-asian="6pt" style:font-weight-asian="bold" style:font-size-complex="6pt" style:font-weight-complex="bold"/>
</style:style>
<style:style style:name="P82" style:family="paragraph">
<style:style style:name="P83" style:family="paragraph" style:parent-style-name="Standard">
<style:paragraph-properties fo:margin-left="0cm" fo:margin-right="0cm" fo:text-align="start" style:justify-single-word="false" fo:text-indent="0cm" style:auto-text-indent="false" style:shadow="none">
<style:tab-stops>
<style:tab-stop style:position="0.079cm"/>
</style:tab-stops>
</style:paragraph-properties>
<style:text-properties style:use-window-font-color="true" style:font-name="Liberation Sans" fo:font-size="7pt" fo:font-weight="bold" officeooo:rsid="0041e7cd" officeooo:paragraph-rsid="0114a1d0" fo:background-color="#eeeeee" style:font-size-asian="7pt" style:font-weight-asian="bold" style:font-size-complex="7pt" style:font-weight-complex="bold"/>
</style:style>
<style:style style:name="P84" style:family="paragraph" style:parent-style-name="Standard">
<style:paragraph-properties fo:margin-left="0cm" fo:margin-right="0cm" fo:text-align="start" style:justify-single-word="false" fo:text-indent="0cm" style:auto-text-indent="false" style:shadow="none">
<style:tab-stops>
<style:tab-stop style:position="0.079cm"/>
</style:tab-stops>
</style:paragraph-properties>
<style:text-properties style:font-name="Liberation Sans" fo:font-size="7pt" fo:font-weight="bold" officeooo:rsid="0041e7cd" officeooo:paragraph-rsid="0114a1d0" fo:background-color="#eeeeee" style:font-size-asian="7pt" style:font-weight-asian="bold" style:font-size-complex="7pt" style:font-weight-complex="bold"/>
</style:style>
<style:style style:name="P85" style:family="paragraph" style:parent-style-name="Untitled1">
<style:text-properties fo:font-size="6pt" fo:font-weight="bold" officeooo:paragraph-rsid="01533b4c" style:font-size-asian="6pt" style:font-weight-asian="bold" style:font-size-complex="6pt" style:font-weight-complex="bold"/>
</style:style>
<style:style style:name="P86" style:family="paragraph" style:parent-style-name="Untitled1">
<style:text-properties fo:font-size="6pt" fo:font-weight="normal" officeooo:paragraph-rsid="01533b4c" style:font-size-asian="6pt" style:font-weight-asian="normal" style:font-size-complex="6pt" style:font-weight-complex="normal"/>
</style:style>
<style:style style:name="P87" style:family="paragraph" style:parent-style-name="Untitled1">
<style:text-properties officeooo:paragraph-rsid="00cfc6a7"/>
</style:style>
<style:style style:name="P88" style:family="paragraph" style:parent-style-name="Untitled1">
<style:paragraph-properties fo:margin-left="0cm" fo:margin-right="0cm" fo:text-align="center" style:justify-single-word="false" fo:text-indent="0cm" style:auto-text-indent="false"/>
<style:text-properties style:use-window-font-color="true" fo:font-size="6pt" fo:font-weight="bold" officeooo:paragraph-rsid="01533b4c" style:font-size-asian="6pt" style:font-weight-asian="bold" style:font-size-complex="6pt" style:font-weight-complex="bold"/>
</style:style>
<style:style style:name="P89" style:family="paragraph" style:parent-style-name="Untitled1">
<style:paragraph-properties fo:margin-left="0cm" fo:margin-right="0cm" fo:text-indent="0cm" style:auto-text-indent="false"/>
<style:text-properties fo:font-size="6pt" fo:font-weight="normal" officeooo:paragraph-rsid="01533b4c" style:font-size-asian="6pt" style:font-weight-asian="normal" style:font-size-complex="6pt" style:font-weight-complex="normal"/>
</style:style>
<style:style style:name="P90" style:family="paragraph">
<style:paragraph-properties fo:text-align="center"/>
<style:text-properties fo:font-size="12pt"/>
</style:style>
<style:style style:name="P83" style:family="paragraph">
<style:style style:name="P91" style:family="paragraph">
<style:paragraph-properties fo:text-align="center"/>
</style:style>
<style:style style:name="T1" style:family="text">
@ -1501,11 +1532,16 @@
<style:style style:name="T39" style:family="text">
<style:text-properties officeooo:rsid="0146c687"/>
</style:style>
<style:style style:name="fr1" style:family="graphic" style:parent-style-name="Frame">
<style:graphic-properties style:run-through="foreground" style:protect="content size position" style:wrap="run-through" style:number-wrapped-paragraphs="no-limit" style:vertical-pos="from-top" style:vertical-rel="paragraph" style:horizontal-pos="from-left" style:horizontal-rel="paragraph" fo:background-color="transparent" draw:fill="none" draw:fill-color="#ffffff" fo:padding="0cm" fo:border="none" style:shadow="none" draw:shadow-opacity="100%" loext:rel-width-rel="paragraph" loext:rel-height-rel="paragraph" draw:textarea-vertical-align="top">
<style:columns fo:column-count="1" fo:column-gap="0cm"/>
</style:graphic-properties>
</style:style>
<style:style style:name="gr1" style:family="graphic">
<style:graphic-properties svg:stroke-color="#000000" draw:textarea-horizontal-align="center" draw:textarea-vertical-align="middle" style:run-through="foreground" style:wrap="run-through" style:number-wrapped-paragraphs="no-limit" style:vertical-pos="from-top" style:vertical-rel="paragraph" style:horizontal-pos="from-left" style:horizontal-rel="paragraph" draw:wrap-influence-on-position="once-concurrent" loext:allow-overlap="true" style:flow-with-text="false"/>
</style:style>
<style:page-layout style:name="pm1">
<style:page-layout-properties fo:page-width="21.001cm" fo:page-height="29.7cm" style:num-format="1" style:print-orientation="portrait" fo:margin-top="0.6cm" fo:margin-bottom="0.499cm" fo:margin-left="1cm" fo:margin-right="0.6cm" style:writing-mode="lr-tb" style:layout-grid-color="#c0c0c0" style:layout-grid-lines="20" style:layout-grid-base-height="0.706cm" style:layout-grid-ruby-height="0.353cm" style:layout-grid-mode="none" style:layout-grid-ruby-below="false" style:layout-grid-print="false" style:layout-grid-display="false" style:footnote-max-height="0cm">
<style:page-layout-properties fo:page-width="21.001cm" fo:page-height="29.7cm" style:num-format="1" style:print-orientation="portrait" fo:margin-top="0.6cm" fo:margin-bottom="0.4cm" fo:margin-left="1cm" fo:margin-right="0.6cm" style:writing-mode="lr-tb" style:layout-grid-color="#c0c0c0" style:layout-grid-lines="20" style:layout-grid-base-height="0.706cm" style:layout-grid-ruby-height="0.353cm" style:layout-grid-mode="none" style:layout-grid-ruby-below="false" style:layout-grid-print="false" style:layout-grid-display="false" style:footnote-max-height="0cm">
<style:footnote-sep style:width="0.018cm" style:distance-before-sep="0.101cm" style:distance-after-sep="0.101cm" style:line-style="solid" style:adjustment="left" style:rel-width="25%" style:color="#000000"/>
</style:page-layout-properties>
<style:header-style/>
@ -1565,9 +1601,9 @@
<text:sequence-decl text:display-outline-level="0" text:name="Drawing"/>
<text:sequence-decl text:display-outline-level="0" text:name="Figure"/>
</text:sequence-decls>
<text:p text:style-name="P80"><text:placeholder text:placeholder-type="text">&lt;for each=&quot;order in records&quot;&gt;</text:placeholder><text:span text:style-name="T37"><text:placeholder text:placeholder-type="text">&lt;set_lang(company.party.lang and company.party.lang.code or &apos;en_US&apos;)&gt;</text:placeholder></text:span><text:span text:style-name="T37"><text:placeholder text:placeholder-type="text">&lt;order.set_lang(company.party.lang and company.party.lang.code or &apos;en_US&apos;)&gt;</text:placeholder></text:span></text:p>
<text:p text:style-name="P81"><text:placeholder text:placeholder-type="text">&lt;for each=&quot;copy in range(1,copies + 1)&quot;&gt;</text:placeholder></text:p>
<text:p text:style-name="P26"><text:span text:style-name="T19"><text:s/></text:span><text:placeholder text:placeholder-type="text">&lt;if test=&quot;copy == 1&quot;&gt;</text:placeholder></text:p>
<text:p text:style-name="P81"><text:placeholder text:placeholder-type="text">&lt;for each=&quot;order in records&quot;&gt;</text:placeholder><text:span text:style-name="T37"><text:placeholder text:placeholder-type="text">&lt;set_lang(company.party.lang and company.party.lang.code or &apos;en_US&apos;)&gt;</text:placeholder></text:span><text:span text:style-name="T37"><text:placeholder text:placeholder-type="text">&lt;order.set_lang(company.party.lang and company.party.lang.code or &apos;en_US&apos;)&gt;</text:placeholder></text:span></text:p>
<text:p text:style-name="P82"><text:placeholder text:placeholder-type="text">&lt;for each=&quot;copy in range(1,copies + 1)&quot;&gt;</text:placeholder></text:p>
<text:p text:style-name="P26"><text:placeholder text:placeholder-type="text">&lt;if test=&quot;copy == 1&quot;&gt;</text:placeholder></text:p>
<table:table table:name="Table15" table:style-name="Table15">
<table:table-column table:style-name="Table15.A"/>
<table:table-row table:style-name="Table15.1">
@ -1647,11 +1683,11 @@
<table:table-column table:style-name="Table10.k"/>
<table:table-row table:style-name="Table10.1">
<table:table-cell table:style-name="Table10.A1" office:value-type="string">
<text:p text:style-name="P66"><draw:line text:anchor-type="paragraph" draw:z-index="0" draw:style-name="gr1" draw:text-style-name="P83" svg:x1="14.222cm" svg:y1="9.894cm" svg:x2="14.222cm" svg:y2="15.884cm">
<text:p text:style-name="P66"><draw:line text:anchor-type="paragraph" draw:z-index="0" draw:style-name="gr1" draw:text-style-name="P91" svg:x1="14.222cm" svg:y1="10.834cm" svg:x2="14.222cm" svg:y2="16.824cm">
<text:p/>
</draw:line><draw:line text:anchor-type="paragraph" draw:z-index="1" draw:style-name="gr1" draw:text-style-name="P82" svg:x1="16.709cm" svg:y1="9.865cm" svg:x2="16.709cm" svg:y2="15.896cm">
</draw:line><draw:line text:anchor-type="paragraph" draw:z-index="1" draw:style-name="gr1" draw:text-style-name="P90" svg:x1="16.709cm" svg:y1="10.777cm" svg:x2="16.709cm" svg:y2="16.808cm">
<text:p/>
</draw:line><draw:line text:anchor-type="paragraph" draw:z-index="2" draw:style-name="gr1" draw:text-style-name="P82" svg:x1="12.002cm" svg:y1="9.863cm" svg:x2="12.002cm" svg:y2="15.896cm">
</draw:line><draw:line text:anchor-type="paragraph" draw:z-index="2" draw:style-name="gr1" draw:text-style-name="P90" svg:x1="12.002cm" svg:y1="10.759cm" svg:x2="12.002cm" svg:y2="16.792cm">
<text:p/>
</draw:line>1</text:p>
</table:table-cell>
@ -1768,7 +1804,7 @@
<table:covered-table-cell/>
<table:covered-table-cell/>
<table:table-cell table:style-name="Table10.Q3" table:number-columns-spanned="7" office:value-type="string">
<text:p text:style-name="P77"/>
<text:p text:style-name="P85"><text:placeholder text:placeholder-type="text">&lt;order.cmr_template and order.cmr_template.get_section_text(&apos;head-left&apos;, record, company.party.lang) or &apos;&apos;&gt;</text:placeholder></text:p>
</table:table-cell>
<table:covered-table-cell/>
<table:covered-table-cell/>
@ -1786,7 +1822,7 @@
<table:covered-table-cell/>
<table:covered-table-cell/>
<table:table-cell table:style-name="Table10.e3" table:number-columns-spanned="7" office:value-type="string">
<text:p text:style-name="P28"><text:placeholder text:placeholder-type="text">&lt;order.shipment and order.shipment.rec_name&gt;</text:placeholder></text:p>
<text:p text:style-name="P88"><text:placeholder text:placeholder-type="text">&lt;order.cmr_template and order.cmr_template.get_section_text(&apos;head-right&apos;, record, company.party.lang) or &apos;&apos;&gt;</text:placeholder></text:p>
</table:table-cell>
<table:covered-table-cell/>
<table:covered-table-cell/>
@ -2209,7 +2245,7 @@
<table:covered-table-cell/>
<table:covered-table-cell/>
<table:table-cell table:style-name="Table10.Q13" table:number-rows-spanned="2" table:number-columns-spanned="21" office:value-type="string">
<text:p text:style-name="P47"><text:placeholder text:placeholder-type="text">&lt;order.party and order.party.carrier_cmr_comment or &apos;&apos;&gt;</text:placeholder></text:p>
<text:p text:style-name="P89"><text:placeholder text:placeholder-type="text">&lt;order.cmr_template and order.cmr_template.get_section_text(&apos;18&apos;, record, company.party.lang) or &apos;&apos;&gt;</text:placeholder></text:p>
</table:table-cell>
<table:covered-table-cell/>
<table:covered-table-cell/>
@ -2601,7 +2637,7 @@
<table:covered-table-cell/>
<table:covered-table-cell/>
<table:table-cell table:style-name="Table10.Q18" table:number-columns-spanned="21" office:value-type="string">
<text:p text:style-name="P77"/>
<text:p text:style-name="P86"><text:placeholder text:placeholder-type="text">&lt;order.cmr_template and order.cmr_template.get_section_text(&apos;19&apos;, record, company.party.lang) or &apos;&apos;&gt;</text:placeholder></text:p>
</table:table-cell>
<table:covered-table-cell/>
<table:covered-table-cell/>
@ -3074,7 +3110,17 @@
<table:table-cell table:style-name="Table10.A1" office:value-type="string">
<text:p text:style-name="P66">22</text:p>
</table:table-cell>
<table:table-cell table:style-name="Table10.B27" table:number-columns-spanned="6" office:value-type="string">
<table:table-cell table:style-name="Table10.B1" table:number-rows-spanned="2" table:number-columns-spanned="12" office:value-type="string">
<text:p text:style-name="P77"><draw:frame draw:style-name="fr1" draw:name="image: (record.cmr_template and record.cmr_template.get_section_image(&apos;22&apos;), &apos;image/png&apos;)" text:anchor-type="char" svg:x="0.199cm" svg:y="0.041cm" svg:width="5.258cm" style:rel-width="82%" svg:height="2.092cm" style:rel-height="113%" draw:z-index="3">
<draw:text-box>
<text:p text:style-name="P80"/>
</draw:text-box>
</draw:frame></text:p>
<text:p text:style-name="P77"/>
<text:p text:style-name="P77"/>
<text:p text:style-name="P77"/>
<text:p text:style-name="P77"/>
<text:p text:style-name="P77"/>
<text:p text:style-name="P77"/>
</table:table-cell>
<table:covered-table-cell/>
@ -3082,9 +3128,7 @@
<table:covered-table-cell/>
<table:covered-table-cell/>
<table:covered-table-cell/>
<table:table-cell table:style-name="Table10.B1" table:number-columns-spanned="6" office:value-type="string">
<text:p text:style-name="P77"/>
</table:table-cell>
<table:covered-table-cell/>
<table:covered-table-cell/>
<table:covered-table-cell/>
<table:covered-table-cell/>
@ -3127,23 +3171,19 @@
<table:table-cell table:style-name="Table10.A2" table:number-rows-spanned="2" office:value-type="string">
<text:p text:style-name="P66"/>
</table:table-cell>
<table:table-cell table:style-name="Table10.B28" table:number-columns-spanned="6" office:value-type="string">
<text:p text:style-name="P77"/>
</table:table-cell>
<table:covered-table-cell/>
<table:covered-table-cell/>
<table:covered-table-cell/>
<table:covered-table-cell/>
<table:covered-table-cell/>
<table:table-cell table:style-name="Table10.e3" table:number-columns-spanned="6" office:value-type="string">
<text:p text:style-name="P77"/>
</table:table-cell>
<table:covered-table-cell/>
<table:covered-table-cell/>
<table:covered-table-cell/>
<table:covered-table-cell/>
<table:covered-table-cell/>
<table:table-cell table:style-name="Table10.N29" table:number-rows-spanned="2" office:value-type="string">
<table:covered-table-cell/>
<table:covered-table-cell/>
<table:table-cell table:style-name="Table10.N28" table:number-rows-spanned="2" office:value-type="string">
<text:p text:style-name="P77"/>
</table:table-cell>
<table:table-cell table:style-name="Table10.O28" table:number-columns-spanned="9" office:value-type="string">
@ -3269,8 +3309,8 @@
</table:table-cell>
</table:table-row>
</table:table>
<text:p text:style-name="P25"><text:placeholder text:placeholder-type="text">&lt;/for&gt;</text:placeholder></text:p>
<text:p text:style-name="P27"><text:placeholder text:placeholder-type="text">&lt;/for&gt;</text:placeholder></text:p>
<text:p text:style-name="P83"><text:placeholder text:placeholder-type="text">&lt;/for&gt;</text:placeholder></text:p>
<text:p text:style-name="P84"><text:placeholder text:placeholder-type="text">&lt;/for&gt;</text:placeholder></text:p>
</office:text>
</office:body>
</office:document>

127
cmr.py Normal file
View File

@ -0,0 +1,127 @@
# The COPYRIGHT file at the top level of this repository contains the full
# copyright notices and license terms.
import os
from trytond.model import fields, ModelSQL, ModelView, DeactivableMixin
from trytond.pool import Pool
from trytond.pyson import Eval
from trytond.transaction import Transaction
from trytond.modules.company import CompanyReport
from .load import NoteMixin
from genshi.template import TextTemplate
__all__ = ['CMRTemplate', 'CMRTemplateLine', 'CMR']
file_id = 'cmr_template_image_id'
store_prefix = None
class CMRTemplate(DeactivableMixin, ModelSQL, ModelView):
'''CMR Template'''
__name__ = 'carrier.load.cmr.template'
name = fields.Char('Name', required=True)
lines = fields.One2Many('carrier.load.cmr.template.line', 'template',
'Lines')
def get_section(self, section):
for line in self.lines:
if line.section == section:
return line
def get_section_text(self, section, record=None, lang=None):
line = self.get_section(section)
if not line:
return ''
if not lang or lang == Transaction().context['language']:
text = line.text
else:
with Transaction().set_context(language=lang):
text = line.__class__(line.id).text
return self.eval(text, record)
def get_section_image(self, section):
line = self.get_section(section)
if not line or not line.image:
# use a blank image to avoid failed render icon
blank = os.path.join(os.path.dirname(__file__), 'images',
'blank.png')
with open(blank, 'rb') as fp:
return fp.read()
return line.image
@classmethod
def eval(cls, expression, record, engine='genshi'):
engine_method = getattr(cls, '_engine_' + engine)
return engine_method(expression, record)
@staticmethod
def template_context(record):
User = Pool().get('res.user')
user = None
if Transaction().user:
user = User(Transaction().user)
return {
'record': record,
'user': user,
}
@classmethod
def _engine_genshi(cls, expression, record):
if not expression:
return ''
template = TextTemplate(expression)
template_context = cls.template_context(record)
return template.generate(**template_context).render()
class CMRTemplateLine(ModelSQL, ModelView):
'''CMR Template Line'''
__name__ = 'carrier.load.cmr.template.line'
template = fields.Many2One('carrier.load.cmr.template', 'Template',
required=True, select=True)
section = fields.Selection([
('13', '13 - Instructions'),
('18', '18 - Carrier reservations'),
('19', '19 - Special agreements'),
('22', '22 - Signature & stamp of sender'),
('head-right', 'Head right'),
('head-left', 'Head left')], 'Section', required=True)
text = fields.Text('Text', translate=True, states={
'invisible': (Eval('section') == '22'),
},
help='Define static text or expression to evaluate with '
'current load order (eg. ${record.shipment.number})',
depends=['section'])
image = fields.Binary('Image', file_id='image_id',
store_prefix=store_prefix, states={
'invisible': (Eval('section') != '22'),
'required': (Eval('section') == '22')
},
depends=['section'])
image_id = fields.Char('Image ID', readonly=True)
class CMR(NoteMixin, CompanyReport):
"""CMR report"""
__name__ = 'carrier.load.order.cmr'
@classmethod
def get_context(cls, records, data):
Configuration = Pool().get('carrier.configuration')
report_context = super(CMR, cls).get_context(records, data)
report_context['copies'] = Configuration(1).cmr_copies or 3
return report_context
@classmethod
def instructions(cls, order, language):
Order = Pool().get('carrier.load.order')
with Transaction().set_context(language=language):
value = Order(order.id).cmr_instructions
if value:
value = value.splitlines()
return value or []

67
cmr.xml Normal file
View File

@ -0,0 +1,67 @@
<?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="cmr_template_view_form">
<field name="model">carrier.load.cmr.template</field>
<field name="type">form</field>
<field name="name">cmr_template_form</field>
</record>
<record model="ir.ui.view" id="cmr_template_view_list">
<field name="model">carrier.load.cmr.template</field>
<field name="type">tree</field>
<field name="name">cmr_template_list</field>
</record>
<record model="ir.action.act_window" id="act_cmr_template">
<field name="name">CMR templates</field>
<field name="res_model">carrier.load.cmr.template</field>
<field name="search_value"></field>
<field name="domain"></field>
<field name="context"></field>
</record>
<record model="ir.action.act_window.view" id="act_cmr_template_view1">
<field name="sequence" eval="10"/>
<field name="view" ref="cmr_template_view_list"/>
<field name="act_window" ref="act_cmr_template"/>
</record>
<record model="ir.action.act_window.view" id="act_cmr_template_view2">
<field name="sequence" eval="20"/>
<field name="view" ref="cmr_template_view_form"/>
<field name="act_window" ref="act_cmr_template"/>
</record>
<record model="ir.model.access" id="access_cmr_template">
<field name="model" search="[('model', '=', 'carrier.load.cmr.template')]"/>
<field name="perm_read" eval="True"/>
<field name="perm_write" eval="False"/>
<field name="perm_create" eval="False"/>
<field name="perm_delete" eval="False"/>
</record>
<record model="ir.model.access" id="access_cmr_template_group_carrier_admin">
<field name="model" search="[('model', '=', 'carrier.load.cmr.template')]"/>
<field name="group" ref="carrier.group_carrier_admin"/>
<field name="perm_read" eval="True"/>
<field name="perm_write" eval="True"/>
<field name="perm_create" eval="True"/>
<field name="perm_delete" eval="True"/>
</record>
<menuitem id="menu_cmr_template" name="CMR Templates"
parent="carrier_configuration.menu_configuration" action="act_cmr_template"
sequence="30"/>
<!-- Line -->
<record model="ir.ui.view" id="cmr_template_line_view_form">
<field name="model">carrier.load.cmr.template.line</field>
<field name="type">form</field>
<field name="name">cmr_template_line_form</field>
</record>
<record model="ir.ui.view" id="cmr_template_line_view_list">
<field name="model">carrier.load.cmr.template.line</field>
<field name="type">tree</field>
<field name="name">cmr_template_line_list</field>
</record>
</data>
</tryton>

View File

@ -1,11 +1,13 @@
# The COPYRIGHT file at the top level of
# this repository contains the full copyright notices and license terms.
from trytond.model import ModelSQL, ModelView, fields
from trytond.model import ModelSQL, fields
from trytond.pool import Pool, PoolMeta
from trytond.pyson import Eval
from trytond.transaction import Transaction
from trytond.modules.company.model import CompanyValueMixin
from trytond.tools.multivalue import migrate_property
from trytond import backend
from sql import Literal
__all__ = ['Configuration', 'ConfigurationSequence']
@ -49,7 +51,7 @@ class Configuration(metaclass=PoolMeta):
('code', '=', 'carrier.load.order')],
required=True))
load_purchasable = fields.Boolean('Load purchasable')
cmr_instructions = fields.Text('CMR instructions', translate=True)
cmr_template = fields.Many2One('carrier.load.cmr.template', 'CMR Template')
cmr_copies = fields.Integer('CMR copies', required=True)
road_note_instructions = fields.Text('Road note instructions', translate=True)
road_note_copies = fields.Integer('Road note copies', required=True)
@ -58,6 +60,77 @@ class Configuration(metaclass=PoolMeta):
vehicle_required = fields.Boolean('Vehicle required')
trailer_required = fields.Boolean('Trailer required')
@classmethod
def __register__(cls, module_name):
pool = Pool()
cursor = Transaction().connection.cursor()
table = cls.__table_handler__(module_name)
sql_table = cls.__table__()
CMRTemplate = pool.get('carrier.load.cmr.template')
CMRTemplateLine = pool.get('carrier.load.cmr.template.line')
cmr_template = CMRTemplate.__table__()
cmr_tline = CMRTemplateLine.__table__()
cmr_instructions = table.column_exist('cmr_instructions')
super().__register__(module_name)
# From 5.0 create default cmr template
if cmr_instructions:
cursor.execute(*cmr_template.insert(columns=[
cmr_template.create_date,
cmr_template.write_date,
cmr_template.create_uid,
cmr_template.write_uid,
cmr_template.name,
cmr_template.active],
values=sql_table.select(
sql_table.create_date,
sql_table.write_date,
sql_table.create_uid,
sql_table.write_uid,
Literal('(Default)'),
Literal(True))))
cursor.execute(*cmr_template.select(
cmr_template.id))
template, = cursor.fetchone()
cursor.execute(*cmr_tline.insert(columns=[
cmr_tline.create_date,
cmr_tline.write_date,
cmr_tline.create_uid,
cmr_tline.write_uid,
cmr_tline.template,
cmr_tline.section,
cmr_tline.text],
values=sql_table.select(
sql_table.create_date,
sql_table.write_date,
sql_table.create_uid,
sql_table.write_uid,
Literal(template),
Literal('13'),
sql_table.cmr_instructions)))
cursor.execute(*cmr_tline.insert(columns=[
cmr_tline.create_date,
cmr_tline.write_date,
cmr_tline.create_uid,
cmr_tline.write_uid,
cmr_tline.template,
cmr_tline.section,
cmr_tline.text],
values=sql_table.select(
sql_table.create_date,
sql_table.write_date,
sql_table.create_uid,
sql_table.write_uid,
Literal(template),
Literal('head-right'),
Literal('${record.shipment and record.shipment.number}'
))))
cursor.execute(*sql_table.update(
[sql_table.cmr_template], [template]))
table.drop_column('cmr_instructions')
@classmethod
def multivalue_model(cls, field):
pool = Pool()

BIN
images/blank.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 479 B

39
load.py
View File

@ -722,6 +722,9 @@ class LoadOrder(Workflow, ModelView, ModelSQL, IncotermDocumentMixin):
cmr_instructions_store = fields.Text('CMR instructions', translate=True,
states={'readonly': Eval('state') == 'cancel'},
depends=['state'])
cmr_template = fields.Function(
fields.Many2One('carrier.load.cmr.template', 'CMR Template'),
'get_cmr_template')
@classmethod
def __setup__(cls):
@ -851,13 +854,18 @@ class LoadOrder(Workflow, ModelView, ModelSQL, IncotermDocumentMixin):
return self.load.currency.round(
Decimal(1 / len(self.load.orders)) * self.load.unit_price)
def get_cmr_template(self, name=None):
if self.party and self.party.cmr_template:
return self.party.cmr_template
Conf = Pool().get('carrier.configuration')
conf = Conf(1)
return conf.cmr_template
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
if self.cmr_template:
return self.cmr_template.get_section_text('13', self)
@classmethod
def set_cmr_instructions(cls, records, name, value):
@ -1480,29 +1488,6 @@ class NoteMixin(object):
return order.company.party
class CMR(NoteMixin, CompanyReport):
"""CMR report"""
__name__ = 'carrier.load.order.cmr'
@classmethod
def get_context(cls, records, data):
Configuration = Pool().get('carrier.configuration')
report_context = super(CMR, cls).get_context(records, data)
report_context['copies'] = Configuration(1).cmr_copies or 3
return report_context
@classmethod
def instructions(cls, order, language):
Order = Pool().get('carrier.load.order')
with Transaction().set_context(language=language):
value = Order(order.id).cmr_instructions
if value:
value = value.splitlines()
return value or []
class RoadTransportNote(NoteMixin, CompanyReport):
"""Road transport note"""
__name__ = 'carrier.load.order.road_note'

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,6 @@
# 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.pool import PoolMeta
from trytond.model import fields
from trytond.pyson import Eval
@ -8,18 +8,17 @@ 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'])
cmr_template = fields.Many2One('carrier.load.cmr.template', 'CMR Template',
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
@classmethod
def __register__(cls, module_name):
table = cls.__table_handler__(module_name)
cmr_instructions = table.column_exist('cmr_instructions')
super().__register__(module_name)
if cmr_instructions:
table.drop_column('cmr_instructions')
table.drop_column('carrier_cmr_comment')

View File

@ -120,7 +120,7 @@ setup(name=name,
package_data={
'trytond.modules.carrier_load': (info.get('xml', [])
+ ['tryton.cfg', 'view/*.xml', 'locale/*.po', '*.fodt',
'icons/*.svg', 'tests/*.rst']),
'icons/*.svg', 'tests/*.rst', 'images/*.png']),
},
classifiers=[
'Development Status :: 5 - Production/Stable',

View File

@ -243,8 +243,14 @@ Check cmr instructions::
>>> Order = Model.get('carrier.load.order')
>>> Conf = Model.get('carrier.configuration')
>>> CMRTemplate = Model.get('carrier.load.cmr.template')
>>> cmr_template = CMRTemplate(name='default')
>>> cmr_tline = cmr_template.lines.new()
>>> cmr_tline.section = '13'
>>> cmr_tline.text = 'global CMR instructions'
>>> cmr_template.save()
>>> carrier_conf = Conf(1)
>>> carrier_conf.cmr_instructions = 'global CMR instructions'
>>> carrier_conf.cmr_template = cmr_template
>>> carrier_conf.save()
>>> order = Order(load=load)
>>> order.save()
@ -252,7 +258,12 @@ Check cmr instructions::
'global CMR instructions'
>>> order.party = customer
>>> order.save()
>>> customer.cmr_instructions = 'Party instructions'
>>> cmr_template2 = CMRTemplate(name='Customer template')
>>> cmr_tline = cmr_template2.lines.new()
>>> cmr_tline.section = '13'
>>> cmr_tline.text = 'Party instructions'
>>> cmr_template2.save()
>>> customer.cmr_template = cmr_template2
>>> customer.save()
>>> order.cmr_instructions
'Party instructions'

View File

@ -20,4 +20,5 @@ xml:
configuration.xml
stock.xml
sale.xml
party.xml
party.xml
cmr.xml

View File

@ -0,0 +1,10 @@
<?xml version="1.0"?>
<!-- The COPYRIGHT file at the top level of this repository contains the full
copyright notices and license terms. -->
<form>
<label name="name"/>
<field name="name" xexpand="1"/>
<label name="active"/>
<field name="active" xexpand="0" width="25"/>
<field name="lines" colspan="4"/>
</form>

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. -->
<form>
<label name="section"/>
<field name="section"/>
<newline/>
<separator name="text" colspan="4"/>
<field name="text" colspan="4"/>
<label name="image"/>
<field name="image" colspan="3" widget="image"/>
</form>

View File

@ -0,0 +1,8 @@
<?xml version="1.0"?>
<!-- The COPYRIGHT file at the top level of this repository contains the full
copyright notices and license terms. -->
<tree>
<field name="template"/>
<field name="section"/>
<field name="text" expand="1"/>
</tree>

View File

@ -0,0 +1,6 @@
<?xml version="1.0"?>
<!-- The COPYRIGHT file at the top level of this repository contains the full
copyright notices and license terms. -->
<tree>
<field name="name" expand="1"/>
</tree>

View File

@ -20,9 +20,8 @@ this repository contains the full copyright notices and license terms. -->
<page id="cmr" string="CMR">
<label name="cmr_copies"/>
<field name="cmr_copies"/>
<newline/>
<label name="cmr_instructions"/>
<field name="cmr_instructions" colspan="3"/>
<label name="cmr_template"/>
<field name="cmr_template"/>
</page>
</xpath>
<xpath expr="/form/notebook" position="inside">

View File

@ -4,10 +4,8 @@
<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" />
<label name="cmr_template"/>
<field name="cmr_template"/>
</page>
</xpath>
</data>