Merge lp:~npg-team/openobject-addons/shipping_api_ups_npg into lp:openobject-addons
- shipping_api_ups_npg
- Merge into trunk
Status: | Rejected |
---|---|
Rejected by: | Fabien (Open ERP) |
Proposed branch: | lp:~npg-team/openobject-addons/shipping_api_ups_npg |
Merge into: | lp:openobject-addons |
Diff against target: |
8039 lines (+7877/-0) 29 files modified
shipping_api_ups/Change Log.txt (+41/-0) shipping_api_ups/__init__.py (+29/-0) shipping_api_ups/__openerp__.py (+52/-0) shipping_api_ups/report/__init__.py (+25/-0) shipping_api_ups/report/label_print.py (+62/-0) shipping_api_ups/report/label_print.rml (+59/-0) shipping_api_ups/report/multiple_label_print.rml (+67/-0) shipping_api_ups/report/normalized_oo2rml.xsl (+696/-0) shipping_api_ups/report/summary_report.py (+55/-0) shipping_api_ups/report/summary_report.rml (+97/-0) shipping_api_ups/report/tiny_sxw2rml.py (+377/-0) shipping_api_ups/sale.py (+34/-0) shipping_api_ups/sale_view.xml (+16/-0) shipping_api_ups/security/ir.model.access.csv (+5/-0) shipping_api_ups/shipping_report.xml (+44/-0) shipping_api_ups/stock.py (+2921/-0) shipping_api_ups/stock_package.py (+92/-0) shipping_api_ups/stock_package_view.xml (+107/-0) shipping_api_ups/ups.py (+110/-0) shipping_api_ups/ups_view.xml (+200/-0) shipping_api_ups/wizard/__init__.py (+27/-0) shipping_api_ups/wizard/quick_ship.py (+2418/-0) shipping_api_ups/wizard/quick_ship_view.xml (+74/-0) shipping_api_ups/wizard/summary_report_view.xml (+30/-0) shipping_api_ups/wizard/summary_report_wizard.py (+57/-0) shipping_api_ups/wizard/update_shipping.py (+63/-0) shipping_api_ups/wizard/update_shipping_view.xml (+31/-0) shipping_api_ups/wizard/xml2dic.py (+44/-0) shipping_api_ups/xml2dic.py (+44/-0) |
To merge this branch: | bzr merge lp:~npg-team/openobject-addons/shipping_api_ups_npg |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Olivier Dony (Odoo) | policy + quick technical scan | Disapprove | |
Review via email: mp+78439@code.launchpad.net |
Commit message
Description of the change
NovaPoint Group has developed this module to provide an UPS extension for the shipping api
Fabien (Open ERP) (fp-tinyerp) wrote : | # |
Olivier Dony (Odoo) (odo-openerp) wrote : | # |
Hello,
I would like to explain a little bit more why this merge proposal was rejected, in 2 parts: our policy for merge proposals, then some specific hints.
1. Merge Proposal Acceptance Policy
=======
There may have been contradicting messages about how and when it is useful to make a merge proposal.
We would like to state this policy very clearly, especially now that extra-addons have been deprecated due to the introduction of OpenERP Apps. So we have now added an official Merge Proposal Acceptance Policy to our contributor documentation, please have a look: http://
2. Remarks specific to this merge proposal
=======
In approximate order of importance:
- based on your minimal description (it would help to have more), it looks like this module is a general purpose extra feature that could be published on OpenERP Apps as explained in the policy, but does not need to be included in official addons now
- the size of the merge proposal diff is extremely large (+8000 lines) compared to the scope:
+ the UPS XML generation code looks duplicated in *MANY* places when it should be much smaller, simpler and modular
+ the XML generation code, on top of being duplicated and too verbose, is mixed inside the business code. It should be part of an abstraction in charge of contacting UPS, and that lies outside of the OpenERP business code: less code, cleaner, more modular and extensible
+ once again, you included a "tiny_sxw2rml.py" script and dependent files that look totally useless and out of place (1100+ lines!)
- lots of duplicated code from shipping_api module, e.g. package_types, etc..
- incorrect use of email template (should not need to evaluate the template yourself)
- outdated mail/email_template API - 6.1 has a new, much cleaner email API, please look at it - your module will not work on 6.1 as it is
- you are overriding methods from original addons without calling super(), and thus duplicating more code
- if this module is related to shipping, why does it add a payment_method on sale.order?
- instead of minidom, OpenERP official addons should use lxml/etree for XML parsing/generation
- adding shipping related field on email.template looks like bad design: breaking encapsulation
- horrible python code for modifying mako templates
- bad python style - see coding guidelines (type comparisons -> isinstance(), dict usage, etc.)
- no proper description of the features in the module manifest, nor how to use them
- a LOT of remaining commented out code lines (thousands of lines!)
- many useless python imports
I hope this helps,
Thanks!
Unmerged revisions
- 5306. By Novapoint Group
-
[Add]: shipping_api_us module to provide an interface for UPS shipping
Preview Diff
1 | === added directory 'shipping_api_ups' |
2 | === added file 'shipping_api_ups/Change Log.txt' |
3 | --- shipping_api_ups/Change Log.txt 1970-01-01 00:00:00 +0000 |
4 | +++ shipping_api_ups/Change Log.txt 2011-10-06 16:08:52 +0000 |
5 | @@ -0,0 +1,41 @@ |
6 | +=============================================================================== |
7 | + Version Change Log (shipping_api_ups) |
8 | +=============================================================================== |
9 | +1.15 (2011-08-19) by Arif |
10 | + * Added validation on shipment process for sale order of CC |
11 | +1.14 (2011-08-10) |
12 | + * Removed dependancy to account_payment_creditcard |
13 | +1.13 (2011-07-06) By Jabir |
14 | + * Add validation of checking shipping packages before doing process shipping |
15 | + |
16 | +1.12 (2011-07-06) By Jabir |
17 | + * Updated shipping charge for first invoice created from delivery order |
18 | +1.11 (2011-07-04) By Jabir |
19 | + * Integrated Canada shipping documents |
20 | +1.9 -> 1.10 (2011-06-10) By Jabir |
21 | + * Automatically create invoice from delivery order if sale order is invoice from picking |
22 | +1.8 -> 1.9 (2011-06-10) By Jabir |
23 | + * Created security rules for models |
24 | + * Updated package weight |
25 | +Version 1.6 -> 1.7 |
26 | + * Fixed the issue with error in Processed Shipping on Delivery Order |
27 | +Version 1.5 -> 1.6 |
28 | + * Fixed the issue with error in Processed Shipping on Delivery Order |
29 | +Version 1.4 -> 1.5 |
30 | + * Moved the credti card charging of pre-authorised payment from shipping to process button on delivery order. |
31 | +Version 1.3 -> 1.4 |
32 | + * Changed the wizard print summary report from old type to new orm.memory type |
33 | +Version 1.02 -> 1.03 |
34 | + *Adding shipping date into Shipping log |
35 | + |
36 | +Version 1.01 -> 1.02 |
37 | + * Changed the wizard update_shipping_status from old type to new orm.memory type |
38 | +Version 1.00 -> 1.01 |
39 | + * Fixed direct delivery order creating creating issue |
40 | +Version 1.0 |
41 | + * Created shipping label report |
42 | + * Created Quick ship wizard |
43 | + * Wizard to print summary report |
44 | + * Wizard to update the status of shipping log |
45 | + * Shipping using ups api |
46 | + * Summary report |
47 | |
48 | === added file 'shipping_api_ups/__init__.py' |
49 | --- shipping_api_ups/__init__.py 1970-01-01 00:00:00 +0000 |
50 | +++ shipping_api_ups/__init__.py 2011-10-06 16:08:52 +0000 |
51 | @@ -0,0 +1,29 @@ |
52 | +# -*- coding: utf-8 -*- |
53 | +############################################################################## |
54 | +# |
55 | +# OpenERP, Open Source Management Solution |
56 | +# Copyright (C) 2011 NovaPoint Group LLC (<http://www.novapointgroup.com>) |
57 | +# Copyright (C) 2004-2010 OpenERP SA (<http://www.openerp.com>) |
58 | +# |
59 | +# This program is free software: you can redistribute it and/or modify |
60 | +# it under the terms of the GNU General Public License as published by |
61 | +# the Free Software Foundation, either version 3 of the License, or |
62 | +# (at your option) any later version. |
63 | +# |
64 | +# This program is distributed in the hope that it will be useful, |
65 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
66 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
67 | +# GNU General Public License for more details. |
68 | +# |
69 | +# You should have received a copy of the GNU General Public License |
70 | +# along with this program. If not, see <http://www.gnu.org/licenses/> |
71 | +# |
72 | +############################################################################## |
73 | + |
74 | +import ups |
75 | +import stock |
76 | +import wizard |
77 | +import stock_package |
78 | +import report |
79 | +import sale |
80 | +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: |
81 | \ No newline at end of file |
82 | |
83 | === added file 'shipping_api_ups/__openerp__.py' |
84 | --- shipping_api_ups/__openerp__.py 1970-01-01 00:00:00 +0000 |
85 | +++ shipping_api_ups/__openerp__.py 2011-10-06 16:08:52 +0000 |
86 | @@ -0,0 +1,52 @@ |
87 | +# -*- coding: utf-8 -*- |
88 | +############################################################################## |
89 | +# |
90 | +# OpenERP, Open Source Management Solution |
91 | +# Copyright (C) 2011 NovaPoint Group LLC (<http://www.novapointgroup.com>) |
92 | +# Copyright (C) 2004-2010 OpenERP SA (<http://www.openerp.com>) |
93 | +# |
94 | +# This program is free software: you can redistribute it and/or modify |
95 | +# it under the terms of the GNU General Public License as published by |
96 | +# the Free Software Foundation, either version 3 of the License, or |
97 | +# (at your option) any later version. |
98 | +# |
99 | +# This program is distributed in the hope that it will be useful, |
100 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
101 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
102 | +# GNU General Public License for more details. |
103 | +# |
104 | +# You should have received a copy of the GNU General Public License |
105 | +# along with this program. If not, see <http://www.gnu.org/licenses/> |
106 | +# |
107 | +############################################################################## |
108 | + |
109 | +{ |
110 | + 'name': 'Shipping API', |
111 | + 'version': '1.15', |
112 | + 'category': 'Generic Modules/Others', |
113 | + 'description': """ |
114 | + """, |
115 | + 'author': 'NovaPoint Group LLC', |
116 | + 'website': ' http://www.novapointgroup.com', |
117 | + 'depends': ['base','sale','sale_weight', |
118 | + 'stock','shipping_api', |
119 | + 'partner_address_validation', |
120 | + 'email_template', |
121 | + 'sale_negotiated_shipping'], |
122 | + 'init_xml': [], |
123 | + 'update_xml': [ |
124 | + 'wizard/update_shipping_view.xml', |
125 | + 'wizard/summary_report_view.xml', |
126 | + 'wizard/quick_ship_view.xml', |
127 | + 'ups_view.xml', |
128 | + 'stock_package_view.xml', |
129 | + 'shipping_report.xml', |
130 | + 'security/ir.model.access.csv', |
131 | + |
132 | + ], |
133 | + 'demo_xml': [ |
134 | + ], |
135 | + 'installable': True, |
136 | + 'active': False, |
137 | +} |
138 | +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: |
139 | |
140 | === added directory 'shipping_api_ups/report' |
141 | === added file 'shipping_api_ups/report/__init__.py' |
142 | --- shipping_api_ups/report/__init__.py 1970-01-01 00:00:00 +0000 |
143 | +++ shipping_api_ups/report/__init__.py 2011-10-06 16:08:52 +0000 |
144 | @@ -0,0 +1,25 @@ |
145 | +# -*- coding: utf-8 -*- |
146 | +############################################################################## |
147 | +# |
148 | +# OpenERP, Open Source Management Solution |
149 | +# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>). |
150 | +# |
151 | +# This program is free software: you can redistribute it and/or modify |
152 | +# it under the terms of the GNU Affero General Public License as |
153 | +# published by the Free Software Foundation, either version 3 of the |
154 | +# License, or (at your option) any later version. |
155 | +# |
156 | +# This program is distributed in the hope that it will be useful, |
157 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
158 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
159 | +# GNU Affero General Public License for more details. |
160 | +# |
161 | +# You should have received a copy of the GNU Affero General Public License |
162 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. |
163 | +# |
164 | +############################################################################## |
165 | + |
166 | +import label_print |
167 | +import summary_report |
168 | +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: |
169 | + |
170 | |
171 | === added file 'shipping_api_ups/report/label_print.py' |
172 | --- shipping_api_ups/report/label_print.py 1970-01-01 00:00:00 +0000 |
173 | +++ shipping_api_ups/report/label_print.py 2011-10-06 16:08:52 +0000 |
174 | @@ -0,0 +1,62 @@ |
175 | +# -*- coding: utf-8 -*- |
176 | +############################################################################## |
177 | +# |
178 | +# OpenERP, Open Source Management Solution |
179 | +# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>). |
180 | +# |
181 | +# This program is free software: you can redistribute it and/or modify |
182 | +# it under the terms of the GNU Affero General Public License as |
183 | +# published by the Free Software Foundation, either version 3 of the |
184 | +# License, or (at your option) any later version. |
185 | +# |
186 | +# This program is distributed in the hope that it will be useful, |
187 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
188 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
189 | +# GNU Affero General Public License for more details. |
190 | +# |
191 | +# You should have received a copy of the GNU Affero General Public License |
192 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. |
193 | +# |
194 | +############################################################################## |
195 | + |
196 | +import time |
197 | +from report import report_sxw |
198 | +from tools import amount_to_text_en |
199 | + |
200 | +class report_print_label(report_sxw.rml_parse): |
201 | + def __init__(self, cr, uid, name, context): |
202 | + super(report_print_label, self).__init__(cr, uid, name, context) |
203 | + self.number_lines = 0 |
204 | + self.number_add = 0 |
205 | + self.localcontext.update({ |
206 | + 'time': time, |
207 | + }) |
208 | + |
209 | + |
210 | + |
211 | + |
212 | +report_sxw.report_sxw( |
213 | + 'report.ship.label.print', |
214 | + 'stock.packages', |
215 | + 'addons/shipping_api_ups/report/label_print.rml', |
216 | + parser=report_print_label,header=False |
217 | +) |
218 | +report_sxw.report_sxw( |
219 | + 'report.ship.log.label.print', |
220 | + 'shipping.move', |
221 | + 'addons/shipping_api_ups/report/label_print.rml', |
222 | + parser=report_print_label,header=False |
223 | +) |
224 | +report_sxw.report_sxw( |
225 | + 'report.quick.ship.label.print', |
226 | + 'quick.ship', |
227 | + 'addons/shipping_api_ups/report/label_print.rml', |
228 | + parser=report_print_label,header=False |
229 | +) |
230 | +report_sxw.report_sxw( |
231 | + 'report.multiple.label.print', |
232 | + 'stock.picking', |
233 | + 'addons/shipping_api_ups/report/multiple_label_print.rml', |
234 | + parser=report_print_label,header=False |
235 | +) |
236 | +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: |
237 | |
238 | === added file 'shipping_api_ups/report/label_print.rml' |
239 | --- shipping_api_ups/report/label_print.rml 1970-01-01 00:00:00 +0000 |
240 | +++ shipping_api_ups/report/label_print.rml 2011-10-06 16:08:52 +0000 |
241 | @@ -0,0 +1,59 @@ |
242 | +<?xml version="1.0"?> |
243 | +<document filename="test.pdf"> |
244 | + <template pageSize="(308.0,434.0)" title="Test" author="Martin Simon" allowSplitting="20"> |
245 | + <pageTemplate id="first"> |
246 | + <frame id="first" x1="-98.0" y1="-30" width="500" height="468"/> |
247 | + </pageTemplate> |
248 | + </template> |
249 | + <stylesheet> |
250 | + <blockTableStyle id="Standard_Outline"> |
251 | + <blockAlignment value="LEFT"/> |
252 | + <blockValign value="TOP"/> |
253 | + </blockTableStyle> |
254 | + <blockTableStyle id="Table1"> |
255 | + <blockAlignment value="LEFT"/> |
256 | + <blockValign value="TOP"/> |
257 | + </blockTableStyle> |
258 | + <initialize> |
259 | + <paraStyle name="all" alignment="justify"/> |
260 | + </initialize> |
261 | + <paraStyle name="P1" fontName="Times-Roman" fontSize="9.0" leading="11"/> |
262 | + <paraStyle name="P2" rightIndent="0.0" leftIndent="0.0" fontName="Helvetica" fontSize="8.0" leading="10" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/> |
263 | + <paraStyle name="Standard" fontName="Times-Roman"/> |
264 | + <paraStyle name="Heading" fontName="Helvetica" fontSize="12.0" leading="15" spaceBefore="12.0" spaceAfter="6.0"/> |
265 | + <paraStyle name="Text body" fontName="Times-Roman" spaceBefore="0.0" spaceAfter="6.0"/> |
266 | + <paraStyle name="List" fontName="Times-Roman" spaceBefore="0.0" spaceAfter="6.0"/> |
267 | + <paraStyle name="Caption" fontName="Times-Roman" fontSize="12.0" leading="15" spaceBefore="6.0" spaceAfter="6.0"/> |
268 | + <paraStyle name="Index" fontName="Times-Roman"/> |
269 | + <paraStyle name="Table Contents" fontName="Times-Roman" spaceBefore="0.0" spaceAfter="6.0"/> |
270 | + <paraStyle name="Table Heading" fontName="Times-Roman" alignment="CENTER" spaceBefore="0.0" spaceAfter="6.0"/> |
271 | + <paraStyle name="Footer" fontName="Times-Roman"/> |
272 | + <paraStyle name="Horizontal Line" fontName="Times-Roman" fontSize="6.0" leading="8" spaceBefore="0.0" spaceAfter="14.0"/> |
273 | + <paraStyle name="terp_header" fontName="Helvetica-Bold" fontSize="15.0" leading="19" alignment="LEFT" spaceBefore="12.0" spaceAfter="6.0"/> |
274 | + <paraStyle name="Heading 9" fontName="Helvetica-Bold" fontSize="75%" leading="NaN" spaceBefore="12.0" spaceAfter="6.0"/> |
275 | + <paraStyle name="terp_tblheader_General" fontName="Helvetica-Bold" fontSize="8.0" leading="10" alignment="LEFT" spaceBefore="6.0" spaceAfter="6.0"/> |
276 | + <paraStyle name="terp_tblheader_Details" fontName="Helvetica-Bold" fontSize="9.0" leading="11" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/> |
277 | + <paraStyle name="terp_default_8" fontName="Helvetica" fontSize="8.0" leading="10" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/> |
278 | + <paraStyle name="terp_default_Bold_8" fontName="Helvetica-Bold" fontSize="8.0" leading="10" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/> |
279 | + <paraStyle name="terp_tblheader_General_Centre" fontName="Helvetica-Bold" fontSize="8.0" leading="10" alignment="CENTER" spaceBefore="6.0" spaceAfter="6.0"/> |
280 | + <paraStyle name="terp_tblheader_General_Right" fontName="Helvetica-Bold" fontSize="8.0" leading="10" alignment="RIGHT" spaceBefore="6.0" spaceAfter="6.0"/> |
281 | + <paraStyle name="terp_tblheader_Details_Centre" fontName="Helvetica-Bold" fontSize="9.0" leading="11" alignment="CENTER" spaceBefore="0.0" spaceAfter="0.0"/> |
282 | + <paraStyle name="terp_tblheader_Details_Right" fontName="Helvetica-Bold" fontSize="9.0" leading="11" alignment="RIGHT" spaceBefore="0.0" spaceAfter="0.0"/> |
283 | + <paraStyle name="terp_default_Right_8" fontName="Helvetica" fontSize="8.0" leading="10" alignment="RIGHT" spaceBefore="0.0" spaceAfter="0.0"/> |
284 | + <paraStyle name="terp_default_Centre_8" fontName="Helvetica" fontSize="8.0" leading="10" alignment="CENTER" spaceBefore="0.0" spaceAfter="0.0"/> |
285 | + <paraStyle name="terp_header_Right" fontName="Helvetica-Bold" fontSize="15.0" leading="19" alignment="LEFT" spaceBefore="12.0" spaceAfter="6.0"/> |
286 | + <paraStyle name="terp_header_Centre" fontName="Helvetica-Bold" fontSize="15.0" leading="19" alignment="CENTER" spaceBefore="12.0" spaceAfter="6.0"/> |
287 | + <paraStyle name="terp_default_address" fontName="Helvetica" fontSize="10.0" leading="13" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/> |
288 | + <paraStyle name="terp_default_9" rightIndent="0.0" leftIndent="0.0" fontName="Helvetica" fontSize="9.0" leading="11" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/> |
289 | + <paraStyle name="terp_default_Bold_9" fontName="Helvetica-Bold" fontSize="9.0" leading="11" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/> |
290 | + <paraStyle name="terp_default_Centre_9" fontName="Helvetica" fontSize="9.0" leading="11" alignment="CENTER" spaceBefore="0.0" spaceAfter="0.0"/> |
291 | + <paraStyle name="terp_default_Right_9" fontName="Helvetica" fontSize="9.0" leading="11" alignment="RIGHT" spaceBefore="0.0" spaceAfter="0.0"/> |
292 | + <paraStyle name="terp_default_2" fontName="Helvetica" fontSize="2.0" leading="3" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/> |
293 | + <images/> |
294 | + </stylesheet> |
295 | + <story> |
296 | + <para style="P1">[[ repeatIn(objects,'o') ]]</para> |
297 | + <para style="P2">[[ o.logo and setTag('para','image',{'width':'300','height':'450'}) or removeParentNode('blockTable') ]][[ o.logo ]]</para> |
298 | + </story> |
299 | +</document> |
300 | + |
301 | |
302 | === added file 'shipping_api_ups/report/label_print.sxw' |
303 | Binary files shipping_api_ups/report/label_print.sxw 1970-01-01 00:00:00 +0000 and shipping_api_ups/report/label_print.sxw 2011-10-06 16:08:52 +0000 differ |
304 | === added file 'shipping_api_ups/report/multiple_label_print.rml' |
305 | --- shipping_api_ups/report/multiple_label_print.rml 1970-01-01 00:00:00 +0000 |
306 | +++ shipping_api_ups/report/multiple_label_print.rml 2011-10-06 16:08:52 +0000 |
307 | @@ -0,0 +1,67 @@ |
308 | +<?xml version="1.0"?> |
309 | +<document filename="test.pdf"> |
310 | + <template pageSize="(308.0,434.0)" title="Test" author="Martin Simon" allowSplitting="20"> |
311 | + <pageTemplate id="first"> |
312 | + <frame id="first" x1="-98.0" y1="-30" width="500" height="468"/> |
313 | + </pageTemplate> |
314 | + </template> |
315 | + <stylesheet> |
316 | + <blockTableStyle id="Standard_Outline"> |
317 | + <blockAlignment value="LEFT"/> |
318 | + <blockValign value="TOP"/> |
319 | + </blockTableStyle> |
320 | + <blockTableStyle id="Table1"> |
321 | + <blockAlignment value="LEFT"/> |
322 | + <blockValign value="TOP"/> |
323 | + </blockTableStyle> |
324 | + <initialize> |
325 | + <paraStyle name="all" alignment="justify"/> |
326 | + </initialize> |
327 | + <paraStyle name="P1" rightIndent="0.0" leftIndent="0.0" fontName="Helvetica" fontSize="8.0" leading="10" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/> |
328 | + <paraStyle name="P2" fontName="Times-Roman" fontSize="9.0" leading="11"/> |
329 | + <paraStyle name="P3" rightIndent="0.0" leftIndent="-4.0" fontName="Times-Roman" fontSize="9.0" leading="11"/> |
330 | + <paraStyle name="P4" rightIndent="0.0" leftIndent="0.0" fontName="Helvetica" fontSize="8.0" leading="10" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/> |
331 | + <paraStyle name="P5" rightIndent="0.0" leftIndent="0.0" fontName="Helvetica" fontSize="8.0" leading="10" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/> |
332 | + <paraStyle name="Standard" fontName="Times-Roman"/> |
333 | + <paraStyle name="Heading" fontName="Helvetica" fontSize="12.0" leading="15" spaceBefore="12.0" spaceAfter="6.0"/> |
334 | + <paraStyle name="Text body" fontName="Times-Roman" spaceBefore="0.0" spaceAfter="6.0"/> |
335 | + <paraStyle name="List" fontName="Times-Roman" spaceBefore="0.0" spaceAfter="6.0"/> |
336 | + <paraStyle name="Caption" fontName="Times-Roman" fontSize="12.0" leading="15" spaceBefore="6.0" spaceAfter="6.0"/> |
337 | + <paraStyle name="Index" fontName="Times-Roman"/> |
338 | + <paraStyle name="Table Contents" fontName="Times-Roman" spaceBefore="0.0" spaceAfter="6.0"/> |
339 | + <paraStyle name="Table Heading" fontName="Times-Roman" alignment="CENTER" spaceBefore="0.0" spaceAfter="6.0"/> |
340 | + <paraStyle name="Footer" fontName="Times-Roman"/> |
341 | + <paraStyle name="Horizontal Line" fontName="Times-Roman" fontSize="6.0" leading="8" spaceBefore="0.0" spaceAfter="14.0"/> |
342 | + <paraStyle name="terp_header" fontName="Helvetica-Bold" fontSize="15.0" leading="19" alignment="LEFT" spaceBefore="12.0" spaceAfter="6.0"/> |
343 | + <paraStyle name="Heading 9" fontName="Helvetica-Bold" fontSize="75%" leading="NaN" spaceBefore="12.0" spaceAfter="6.0"/> |
344 | + <paraStyle name="terp_tblheader_General" fontName="Helvetica-Bold" fontSize="8.0" leading="10" alignment="LEFT" spaceBefore="6.0" spaceAfter="6.0"/> |
345 | + <paraStyle name="terp_tblheader_Details" fontName="Helvetica-Bold" fontSize="9.0" leading="11" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/> |
346 | + <paraStyle name="terp_default_8" fontName="Helvetica" fontSize="8.0" leading="10" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/> |
347 | + <paraStyle name="terp_default_Bold_8" fontName="Helvetica-Bold" fontSize="8.0" leading="10" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/> |
348 | + <paraStyle name="terp_tblheader_General_Centre" fontName="Helvetica-Bold" fontSize="8.0" leading="10" alignment="CENTER" spaceBefore="6.0" spaceAfter="6.0"/> |
349 | + <paraStyle name="terp_tblheader_General_Right" fontName="Helvetica-Bold" fontSize="8.0" leading="10" alignment="RIGHT" spaceBefore="6.0" spaceAfter="6.0"/> |
350 | + <paraStyle name="terp_tblheader_Details_Centre" fontName="Helvetica-Bold" fontSize="9.0" leading="11" alignment="CENTER" spaceBefore="0.0" spaceAfter="0.0"/> |
351 | + <paraStyle name="terp_tblheader_Details_Right" fontName="Helvetica-Bold" fontSize="9.0" leading="11" alignment="RIGHT" spaceBefore="0.0" spaceAfter="0.0"/> |
352 | + <paraStyle name="terp_default_Right_8" fontName="Helvetica" fontSize="8.0" leading="10" alignment="RIGHT" spaceBefore="0.0" spaceAfter="0.0"/> |
353 | + <paraStyle name="terp_default_Centre_8" fontName="Helvetica" fontSize="8.0" leading="10" alignment="CENTER" spaceBefore="0.0" spaceAfter="0.0"/> |
354 | + <paraStyle name="terp_header_Right" fontName="Helvetica-Bold" fontSize="15.0" leading="19" alignment="LEFT" spaceBefore="12.0" spaceAfter="6.0"/> |
355 | + <paraStyle name="terp_header_Centre" fontName="Helvetica-Bold" fontSize="15.0" leading="19" alignment="CENTER" spaceBefore="12.0" spaceAfter="6.0"/> |
356 | + <paraStyle name="terp_default_address" fontName="Helvetica" fontSize="10.0" leading="13" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/> |
357 | + <paraStyle name="terp_default_9" rightIndent="0.0" leftIndent="0.0" fontName="Helvetica" fontSize="9.0" leading="11" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/> |
358 | + <paraStyle name="terp_default_Bold_9" fontName="Helvetica-Bold" fontSize="9.0" leading="11" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/> |
359 | + <paraStyle name="terp_default_Centre_9" fontName="Helvetica" fontSize="9.0" leading="11" alignment="CENTER" spaceBefore="0.0" spaceAfter="0.0"/> |
360 | + <paraStyle name="terp_default_Right_9" fontName="Helvetica" fontSize="9.0" leading="11" alignment="RIGHT" spaceBefore="0.0" spaceAfter="0.0"/> |
361 | + <paraStyle name="terp_default_2" fontName="Helvetica" fontSize="2.0" leading="3" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/> |
362 | + <images/> |
363 | + </stylesheet> |
364 | + <story> |
365 | + <para style="P3">[[ repeatIn(objects,'o') ]]</para> |
366 | + <section> |
367 | + <para style="P4"> |
368 | + <font face="Times-Roman" size="9.0">[[repeatIn(o.packages_ids,'p')]]</font> |
369 | + </para> |
370 | + <para style="P1">[[ p.logo and setTag('para','image',{'width':'300','height':'450'}) or removeParentNode('blockTable') ]][[ p.logo ]]</para> |
371 | + </section> |
372 | + </story> |
373 | +</document> |
374 | + |
375 | |
376 | === added file 'shipping_api_ups/report/multiple_label_print.sxw' |
377 | Binary files shipping_api_ups/report/multiple_label_print.sxw 1970-01-01 00:00:00 +0000 and shipping_api_ups/report/multiple_label_print.sxw 2011-10-06 16:08:52 +0000 differ |
378 | === added file 'shipping_api_ups/report/normalized_oo2rml.xsl' |
379 | --- shipping_api_ups/report/normalized_oo2rml.xsl 1970-01-01 00:00:00 +0000 |
380 | +++ shipping_api_ups/report/normalized_oo2rml.xsl 2011-10-06 16:08:52 +0000 |
381 | @@ -0,0 +1,696 @@ |
382 | +<?xml version="1.0" encoding="utf-8"?> |
383 | +<xsl:stylesheet |
384 | + version="1.0" |
385 | + xmlns:xsl="http://www.w3.org/1999/XSL/Transform" |
386 | + xmlns:fo="http://www.w3.org/1999/XSL/Format" |
387 | + xmlns:office="http://openoffice.org/2000/office" |
388 | + xmlns:style="http://openoffice.org/2000/style" |
389 | + xmlns:text="http://openoffice.org/2000/text" |
390 | + xmlns:table="http://openoffice.org/2000/table" |
391 | + xmlns:draw="http://openoffice.org/2000/drawing" |
392 | + xmlns:xlink="http://www.w3.org/1999/xlink" |
393 | + xmlns:number="http://openoffice.org/2000/datastyle" |
394 | + xmlns:svg="http://www.w3.org/2000/svg" |
395 | + xmlns:chart="http://openoffice.org/2000/chart" |
396 | + xmlns:dr3d="http://openoffice.org/2000/dr3d" |
397 | + xmlns:math="http://www.w3.org/1998/Math/MathML" |
398 | + xmlns:form="http://openoffice.org/2000/form" |
399 | + xmlns:script="http://openoffice.org/2000/script" |
400 | + office:class="text" office:version="1.0" |
401 | + exclude-result-prefixes = "xsl fo office style text table draw xlink number svg chart dr3d math form script"> |
402 | + |
403 | + <!--TODO's: indent, picture cache (trml2pdf) --> |
404 | + |
405 | +<xsl:output method="xml" indent="yes" /> |
406 | +<xsl:strip-space elements="*"/> |
407 | + |
408 | +<xsl:key name="text_style" match="style:style[@style:family='text']" use="@style:name" /> |
409 | +<xsl:key name="page_break_before" match="style:style[@style:family='paragraph' and ./style:properties/@fo:break-before='page']" use="@style:name" /> |
410 | +<xsl:key name="page_break_after" match="style:style[@style:family='paragraph' and ./style:properties/@fo:break-after='page']" use="@style:name" /> |
411 | +<xsl:key name="table_column_style" match="style:style[@style:family='table-column']" use="@style:name" /> |
412 | +<xsl:key name="table_cell_style" match="style:style[@style:family='table-cell']" use="@style:name" /> |
413 | +<xsl:key name="paragraph_style" match="style:style[@style:family='paragraph']" use="@style:name" /> |
414 | + |
415 | +<xsl:template match="office:document-content"> |
416 | + <document filename="test.pdf"> |
417 | + <xsl:apply-templates select="office:automatic-styles" /> |
418 | + <xsl:apply-templates select="office:body" /> |
419 | + </document> |
420 | +</xsl:template> |
421 | + |
422 | +<xsl:template name="page_size"> |
423 | + <xsl:attribute name="pageSize"> |
424 | + <xsl:text>(</xsl:text> |
425 | + <xsl:value-of select="//transferredfromstylesxml/style:page-master[1]/style:properties/@fo:page-width" /> |
426 | + <xsl:text>,</xsl:text> |
427 | + <xsl:value-of select="//transferredfromstylesxml/style:page-master[1]/style:properties/@fo:page-height" /> |
428 | + <xsl:text>)</xsl:text> |
429 | + </xsl:attribute> |
430 | +</xsl:template> |
431 | + |
432 | +<xsl:template name="fixed_frame"> |
433 | + <xsl:for-each select="//draw:text-box"> |
434 | + <frame> |
435 | + <xsl:attribute name="id"><xsl:value-of select="./@draw:name" /></xsl:attribute> |
436 | + <xsl:attribute name="x1"><xsl:value-of select="./@svg:x" /></xsl:attribute> |
437 | + <xsl:attribute name="y1"> |
438 | + <xsl:value-of |
439 | + select="//transferredfromstylesxml/style:page-master[1]/style:properties/@fo:page-height - ./@svg:y - ./@fo:min-height" /> |
440 | + </xsl:attribute> |
441 | + <xsl:attribute name="width"> |
442 | + <xsl:value-of select="./@svg:width" /> |
443 | + </xsl:attribute> |
444 | + <xsl:attribute name="height"> |
445 | + <xsl:value-of select="./@fo:min-height" /> |
446 | + </xsl:attribute> |
447 | + </frame> |
448 | + </xsl:for-each> |
449 | +</xsl:template> |
450 | + |
451 | +<xsl:template name="margin_sizes"> |
452 | + <xsl:variable name="margin_left" select="//transferredfromstylesxml/style:page-master[1]/style:properties/@fo:margin-left" /> |
453 | + <xsl:variable name="margin_right" select="//transferredfromstylesxml/style:page-master[1]/style:properties/@fo:margin-right" /> |
454 | + <xsl:variable name="margin_top" select="//transferredfromstylesxml/style:page-master[1]/style:properties/@fo:margin-top" /> |
455 | + <xsl:variable name="margin_bottom" select="//transferredfromstylesxml/style:page-master[1]/style:properties/@fo:margin-bottom" /> |
456 | + <xsl:variable name="page_width" select="//transferredfromstylesxml/style:page-master[1]/style:properties/@fo:page-width" /> |
457 | + <xsl:variable name="page_height" select="//transferredfromstylesxml/style:page-master[1]/style:properties/@fo:page-height" /> |
458 | + <xsl:attribute name="x1"><xsl:value-of select="$margin_left" /></xsl:attribute> |
459 | + <xsl:attribute name="y1"><xsl:value-of select="$margin_bottom" /></xsl:attribute> |
460 | + <xsl:attribute name="width"><xsl:value-of select="$page_width - $margin_left - $margin_right"/></xsl:attribute> |
461 | + <xsl:attribute name="height"><xsl:value-of select="$page_height - $margin_bottom - $margin_top"/></xsl:attribute> |
462 | +</xsl:template> |
463 | + |
464 | +<xsl:template name="text_width"> |
465 | + <!-- You need this for the workaround to make primitive outlines--> |
466 | + <xsl:variable name="margin_left" select="//transferredfromstylesxml/style:page-master[1]/style:properties/@fo:margin-left" /> |
467 | + <xsl:variable name="margin_right" select="//transferredfromstylesxml/style:page-master[1]/style:properties/@fo:margin-right" /> |
468 | + <xsl:variable name="page_width" select="//transferredfromstylesxml/style:page-master[1]/style:properties/@fo:page-width" /> |
469 | + <xsl:value-of select="$page_width - $margin_left - $margin_right - 18"/> |
470 | +</xsl:template> |
471 | + |
472 | + |
473 | + |
474 | +<xsl:template match="office:automatic-styles"> |
475 | + <!--<template pageSize="(21cm, 29.7cm)" leftMargin="1.0cm" rightMargin="2.0cm" topMargin="1.0cm" bottomMargin="1.0cm" title="Test" author="Martin Simon" allowSplitting="20">--> |
476 | + <template pageSize="(21cm, 29.7cm)" title="Test" author="Martin Simon" allowSplitting="20"> |
477 | + <xsl:call-template name="page_size" /> |
478 | + <pageTemplate id="first"> |
479 | + <xsl:call-template name="fixed_frame" /> |
480 | + <frame id="first" x1="2cm" y1="2cm" width="17cm" height="26cm"> |
481 | + <xsl:call-template name="margin_sizes" /> |
482 | + </frame> |
483 | + </pageTemplate> |
484 | + </template> |
485 | + <stylesheet> |
486 | + <!--A table style to simulate primitive outlines -till the <addOutline> tag is implemented in trml2pdf --> |
487 | + <blockTableStyle id="Standard_Outline"> |
488 | + <blockAlignment value="LEFT"/> |
489 | + <blockValign value="TOP"/> |
490 | + </blockTableStyle> |
491 | + <!--use two standard table grid styles like PyOpenOffice "Old Way": with and without a grid--> |
492 | + <!--TODO insert table cell colors here, not within the <td> tag - otherwise |
493 | + it will not work with flowables as cell content--> |
494 | + <xsl:call-template name="make_blocktablestyle" /> |
495 | + <initialize> |
496 | + <paraStyle name="all" alignment="justify" /> |
497 | + </initialize> |
498 | + <xsl:apply-templates select="style:style" /> |
499 | + </stylesheet> |
500 | +</xsl:template> |
501 | + |
502 | +<xsl:template name="make_blocktablestyle"> |
503 | + <xsl:for-each select="//table:table"> |
504 | + <xsl:variable name="test"> |
505 | + <xsl:value-of select="./@table:name" /> |
506 | + </xsl:variable> |
507 | + <xsl:if test="not(boolean(count(preceding-sibling::table:table[@table:name=$test])))"> |
508 | + <!--Test if this is the first table with this style, nested tables not counted--> |
509 | + <blockTableStyle id="{@table:name}"> |
510 | + <xsl:if test=".//draw:image"> |
511 | + <blockTopPadding value="0"/> |
512 | + <blockBottomPadding value="0"/> |
513 | + </xsl:if> |
514 | + <blockAlignment value="LEFT" /> |
515 | + <blockValign value="TOP" /> |
516 | + <xsl:call-template name="make_linestyle" /> |
517 | + <xsl:call-template name="make_tablebackground" /> |
518 | + </blockTableStyle> |
519 | + </xsl:if> |
520 | + </xsl:for-each> |
521 | +</xsl:template> |
522 | + |
523 | +<xsl:template name="make_linestyle"> |
524 | + <xsl:for-each select=".//table:table-row"> |
525 | + <xsl:variable name="row" select="position() - 1"/> |
526 | + <xsl:for-each select=".//table:table-cell"> |
527 | + <xsl:variable name="col" select="position() - 1"/> |
528 | + <xsl:variable name="linebefore"> |
529 | + <xsl:value-of select="key('table_cell_style',@table:style-name)/style:properties/@fo:border-left"/> |
530 | + </xsl:variable> |
531 | + <xsl:if test="not($linebefore='') and not($linebefore='none')"> |
532 | + <xsl:variable name="colorname"> |
533 | + <xsl:value-of select="substring-after($linebefore,'#')"/> |
534 | + </xsl:variable> |
535 | + <lineStyle kind="LINEBEFORE" colorName="#{$colorname}" start="{$col},{$row}" stop="{$col},-1"/> |
536 | + </xsl:if> |
537 | + <xsl:variable name="lineafter"> |
538 | + <xsl:value-of select="key('table_cell_style',@table:style-name)/style:properties/@fo:border-right"/> |
539 | + </xsl:variable> |
540 | + <xsl:if test="not($lineafter='') and not($lineafter='none')"> |
541 | + <xsl:variable name="colorname"> |
542 | + <xsl:value-of select="substring-after($lineafter,'#')"/> |
543 | + </xsl:variable> |
544 | + <lineStyle kind="LINEAFTER" colorName="#{$colorname}" start="{$col},{$row}" stop="{$col},-1"/> |
545 | + </xsl:if> |
546 | + <xsl:variable name="lineabove"> |
547 | + <xsl:value-of select="key('table_cell_style',@table:style-name)/style:properties/@fo:border-top"/> |
548 | + </xsl:variable> |
549 | + <xsl:if test="not($lineabove='') and not($lineabove='none')"> |
550 | + <xsl:variable name="colorname"> |
551 | + <xsl:value-of select="substring-after($lineabove,'#')"/> |
552 | + </xsl:variable> |
553 | + <lineStyle kind="LINEABOVE" colorName="#{$colorname}" start="{$col},{$row}" stop="{$col},{$row}"/> |
554 | + </xsl:if> |
555 | + <xsl:variable name="linebelow"> |
556 | + <xsl:value-of select="key('table_cell_style',@table:style-name)/style:properties/@fo:border-bottom"/> |
557 | + </xsl:variable> |
558 | + <xsl:if test="not($linebelow='') and not($linebelow='none')"> |
559 | + <xsl:variable name="colorname"> |
560 | + <xsl:value-of select="substring-after($linebelow,'#')"/> |
561 | + </xsl:variable> |
562 | + <lineStyle kind="LINEBELOW" colorName="#{$colorname}" start="{$col},{-1}" stop="{$col},{-1}"/> |
563 | + </xsl:if> |
564 | + <xsl:variable name="grid"> |
565 | + <xsl:value-of select="key('table_cell_style',@table:style-name)/style:properties/@fo:border"/> |
566 | + </xsl:variable> |
567 | + <xsl:if test="not($grid='') and not($grid='none')"> |
568 | + <xsl:variable name="colorname"> |
569 | + <xsl:value-of select="substring-after($grid,'#')"/> |
570 | + </xsl:variable> |
571 | + <!-- Don't use grid because we don't need a line between each rows --> |
572 | + <lineStyle kind="LINEBEFORE" colorName="#{$colorname}" start="{$col},{$row}" stop="{$col},-1"/> |
573 | + <lineStyle kind="LINEAFTER" colorName="#{$colorname}" start="{$col},{$row}" stop="{$col},-1"/> |
574 | + <lineStyle kind="LINEABOVE" colorName="#{$colorname}" start="{$col},{$row}" stop="{$col},{$row}"/> |
575 | + <lineStyle kind="LINEBELOW" colorName="#{$colorname}" start="{$col},{-1}" stop="{$col},{-1}"/> |
576 | + </xsl:if> |
577 | + </xsl:for-each> |
578 | + </xsl:for-each> |
579 | +</xsl:template> |
580 | + |
581 | +<!-- Was needed to simulate bulleted lists: |
582 | +<xsl:template match="text:ordered-list|text:unordered-list"> |
583 | + <xsl:variable name = "text_width"> |
584 | + <xsl:call-template name="text_width" /> |
585 | + </xsl:variable> |
586 | + <blockTable style="Standard_Outline" colWidths="18,{$text_width}"> |
587 | + <xsl:apply-templates match="text:list-item" /> |
588 | +</blockTable> |
589 | +</xsl:template> |
590 | + |
591 | +<xsl:template match="text:list-item"> |
592 | + <tr> |
593 | + <td><para><font face="Helvetica-Bold" size="10">*</font></para></td> |
594 | + <td> |
595 | + <xsl:apply-templates /> |
596 | + </td> |
597 | + </tr> |
598 | +</xsl:template> |
599 | + |
600 | +--> |
601 | + |
602 | + |
603 | +<xsl:template match="office:body"> |
604 | + <story> |
605 | + <xsl:apply-templates /> |
606 | + <xsl:for-each select="//draw:text-box"> |
607 | + <currentFrame> |
608 | + <xsl:attribute name="name"> |
609 | + <xsl:value-of select="./@draw:name" /> |
610 | + </xsl:attribute> |
611 | + </currentFrame> |
612 | + <xsl:apply-templates> |
613 | + <xsl:with-param name="skip_draw" select="0" /> |
614 | + </xsl:apply-templates> |
615 | + <frameEnd /> |
616 | + </xsl:for-each> |
617 | + <xsl:for-each select="//text:ordered-list"> |
618 | + <para><seqReset id="{./@text:style-name}"/></para> |
619 | + </xsl:for-each> |
620 | + </story> |
621 | +</xsl:template> |
622 | + |
623 | +<xsl:template match="table:table"> |
624 | + <blockTable> |
625 | + <xsl:attribute name="colWidths"> |
626 | + <xsl:call-template name="make_columns" /> |
627 | + </xsl:attribute> |
628 | + <xsl:call-template name="make_tableheaders" /> |
629 | + <xsl:attribute name="style"> |
630 | + <xsl:value-of select="@table:name" /> |
631 | + </xsl:attribute> |
632 | + <xsl:apply-templates /> |
633 | + </blockTable> |
634 | +</xsl:template> |
635 | + |
636 | +<xsl:template name="make_tableheaders"> |
637 | + <xsl:if test="boolean(count(table:table-header-rows))"> |
638 | + <xsl:attribute name="repeatRows">1</xsl:attribute> |
639 | + </xsl:if> |
640 | +</xsl:template> |
641 | + |
642 | +<xsl:template name="make_tablebackground"> |
643 | + <xsl:for-each select=".//table:table-row"> |
644 | + <!--Be careful when there are table:table-header-rows as |
645 | + parent node of table:table-row --> |
646 | + <xsl:variable name="row" select="position() - 1" /> |
647 | + <xsl:for-each select="./table:table-cell"> |
648 | + <xsl:variable name="col" select="position() - 1" /> |
649 | + <xsl:variable name="background"> |
650 | + <xsl:value-of select="key('table_cell_style',@table:style-name)/style:properties/@fo:background-color" /> |
651 | + </xsl:variable> |
652 | + <xsl:if test="not($background='') and boolean(key('table_cell_style',@table:style-name)/style:properties/@fo:background-color) and starts-with($background,'#')"> |
653 | + <!--only RGB hexcolors are accepted --> |
654 | + <blockBackground colorName="{$background}" start="{$col},{$row}" stop="{$col},-1" /> |
655 | + </xsl:if> |
656 | + </xsl:for-each> |
657 | + </xsl:for-each> |
658 | +</xsl:template> |
659 | + |
660 | +<xsl:template name="make_columns"> |
661 | + <xsl:variable name="columns" > |
662 | + <xsl:for-each select="table:table-column"> |
663 | + <xsl:value-of select="key('table_column_style',@table:style-name)/style:properties/@style:column-width" /> |
664 | + <xsl:text>,</xsl:text> |
665 | + </xsl:for-each> |
666 | + </xsl:variable> |
667 | + <xsl:value-of select="substring($columns,1,string-length($columns) - 1)" /> |
668 | + <!--strip the last comma--> |
669 | +</xsl:template> |
670 | + |
671 | +<xsl:template match="table:table-row"> |
672 | + <tr> |
673 | + <xsl:apply-templates /> |
674 | + </tr> |
675 | +</xsl:template> |
676 | + |
677 | +<xsl:template match="table:table-cell"> |
678 | + <td> |
679 | + <xsl:apply-templates /> |
680 | + </td> |
681 | +</xsl:template> |
682 | + |
683 | +<xsl:template match="text:section"> |
684 | + <section> |
685 | + <xsl:apply-templates /> |
686 | + </section> |
687 | +</xsl:template> |
688 | + |
689 | + |
690 | +<xsl:template match="text:span"> |
691 | + <font> |
692 | + <xsl:call-template name="make_fontnames_span" /> |
693 | + <xsl:call-template name="make_fontsize_span" /> |
694 | + <xsl:apply-templates /> |
695 | + </font> |
696 | +</xsl:template> |
697 | + |
698 | +<xsl:template name="make_fontsize_span"> |
699 | + <xsl:variable name ="fontsize"> |
700 | + <xsl:value-of select="key('text_style',@text:style-name)/style:properties/@fo:font-size" /> |
701 | + </xsl:variable> |
702 | + <xsl:if test="not($fontsize='') and boolean(key('text_style',@text:style-name)/style:properties/@fo:font-size)" > |
703 | + <xsl:attribute name="size"> |
704 | + <xsl:value-of select="$fontsize" /> |
705 | + </xsl:attribute> |
706 | + </xsl:if> |
707 | +</xsl:template> |
708 | + |
709 | +<xsl:template name="make_fontnames_span"> |
710 | + <xsl:attribute name="face"> |
711 | + <xsl:call-template name="make_fontnames"> |
712 | + <xsl:with-param name="fontName" select="key('text_style',@text:style-name)/style:properties/@style:font-name" /> |
713 | + <xsl:with-param name="fontWeight" select="key('text_style',@text:style-name)/style:properties/@fo:font-weight" /> |
714 | + <xsl:with-param name="fontStyle" select="key('text_style',@text:style-name)/style:properties/@fo:font-style" /> |
715 | + </xsl:call-template> |
716 | + </xsl:attribute> |
717 | +</xsl:template> |
718 | + |
719 | +<xsl:template name="make_image"> |
720 | + <illustration height="{.//draw:image/@svg:height}" width="{.//draw:image/@svg:width}"> |
721 | + <image x="0" y="0" file="{substring-after(.//draw:image/@xlink:href,'#Pictures/')}" height="{.//draw:image/@svg:height}" width="{.//draw:image/@svg:width}" /> |
722 | + </illustration> |
723 | +</xsl:template> |
724 | + |
725 | +<xsl:template name="empty_paragraph"> |
726 | + <xsl:if test="not(boolean(count(descendant::node())))"> |
727 | + <xsl:call-template name="distance_point"> |
728 | + <xsl:with-param name="background" select="key('paragraph_style',@text:style-name)/style:properties/@fo:background-color" /> |
729 | + </xsl:call-template> |
730 | + </xsl:if> |
731 | +</xsl:template> |
732 | + |
733 | +<xsl:template name="distance_point"> |
734 | + <xsl:param name="background" /> |
735 | + <xsl:param name="tab_stop"></xsl:param> |
736 | + <xsl:variable name="local_back"> |
737 | + <xsl:choose> |
738 | + <xsl:when test="not(boolean($background)) or not(contains($background,'#'))"> |
739 | + <!-- Do not accept OO colors like "transparent", only hex-colors --> |
740 | + <xsl:text>white</xsl:text> |
741 | + </xsl:when> |
742 | + <xsl:otherwise> |
743 | + <xsl:value-of select="$background" /> |
744 | + </xsl:otherwise> |
745 | + </xsl:choose> |
746 | + </xsl:variable> |
747 | + <font color="{$local_back}"> |
748 | + <xsl:text> </xsl:text> |
749 | + <xsl:if test="boolean($tab_stop)"> |
750 | + <!-- simulate a tabstop with white/background-color points --> |
751 | + <xsl:text>.........</xsl:text> |
752 | + </xsl:if> |
753 | + </font> |
754 | +</xsl:template> |
755 | + |
756 | +<xsl:template match="text:ordered-list"> |
757 | + <xsl:apply-templates /> |
758 | + |
759 | + <!-- Reset the counter. seqreset is not a trml2pdf tag, but a Platypus Intra Paragraph Markup, |
760 | + so it needs a dummy paragraph to enclose it --> |
761 | +</xsl:template> |
762 | + |
763 | +<xsl:template name="make_listitem"> |
764 | + <xsl:if test="(name(..)='text:list-item')"> |
765 | + <xsl:attribute name="leftIndent">15</xsl:attribute> |
766 | + <xsl:attribute name="bulletIndent">0</xsl:attribute> |
767 | + <xsl:choose> |
768 | + <xsl:when test="(name(../..)='text:unordered-list')"> |
769 | + <xsl:variable name="fontsize"> |
770 | + <xsl:value-of select="number(key('paragraph_style',@text:style-name)/style:properties/@fo:font-size)" /> |
771 | + </xsl:variable> |
772 | + <xsl:choose> |
773 | + <xsl:when test="$fontsize='NaN'"> |
774 | + <!-- you should exclude non-numerical values for bulletFontSize. <== Sometimes the preprocessing went wrong.--> |
775 | + <!--use a default bullet font size--> |
776 | + <xsl:attribute name="bulletFontSize">6</xsl:attribute> |
777 | + </xsl:when> |
778 | + <xsl:otherwise> |
779 | + <xsl:attribute name="bulletFontSize"><xsl:value-of select="floor(($fontsize div 2) + 1)" /></xsl:attribute> |
780 | + </xsl:otherwise> |
781 | + </xsl:choose> |
782 | + <xsl:attribute name="bulletFontName">ZapfDingbats</xsl:attribute> |
783 | + <xsl:attribute name="bulletText">l</xsl:attribute> |
784 | + </xsl:when> |
785 | + <xsl:otherwise> |
786 | + <!-- Generate the numbers for an ordered list --> |
787 | + <xsl:variable name="size"> |
788 | + <xsl:value-of select="key('paragraph_style',@text:style-name)/style:properties/@fo:font-size" /> |
789 | + </xsl:variable> |
790 | + <!-- For ordered lists we use the bullet tag from Platypus Intra Paragraph Markup --> |
791 | + <bullet> |
792 | + <xsl:if test="not($size='') and boolean(key('paragraph_style',@text:style-name)/style:properties/@fo:font-size)"> |
793 | + <xsl:attribute name="size"> |
794 | + <!-- adapt the fontsize to the fontsize of the current paragraph --> |
795 | + <xsl:value-of select="$size" /> |
796 | + </xsl:attribute> |
797 | + </xsl:if> |
798 | + <seq id="{../../@text:style-name}"/>.</bullet> |
799 | + |
800 | + </xsl:otherwise> |
801 | + </xsl:choose> |
802 | + </xsl:if> |
803 | +</xsl:template> |
804 | + |
805 | +<xsl:template match="text:drop-down"> |
806 | + <xsl:value-of select="text:label[2]/@text:value" /> |
807 | +</xsl:template> |
808 | + |
809 | + |
810 | +<xsl:template match="text:p|text:h"> |
811 | + <xsl:param name="skip_draw" select="1" /> |
812 | + <xsl:if test="boolean(key('page_break_before',@text:style-name))" > |
813 | + <pageBreak /> |
814 | + </xsl:if> |
815 | + <xsl:choose> |
816 | + <xsl:when test="boolean(.//draw:image)"> |
817 | + <xsl:call-template name="make_image" /> |
818 | + </xsl:when> |
819 | + <xsl:when test="boolean(name(..) = 'draw:text-box') and boolean($skip_draw)"> |
820 | + </xsl:when> |
821 | + <xsl:otherwise> |
822 | + <para> |
823 | + <xsl:attribute name="style"> |
824 | + <xsl:value-of select="@text:style-name" /> |
825 | + </xsl:attribute> |
826 | + <xsl:call-template name="make_listitem" /> |
827 | + <xsl:apply-templates /> |
828 | + <xsl:call-template name="empty_paragraph" /> |
829 | + </para> |
830 | + </xsl:otherwise> |
831 | + </xsl:choose> |
832 | + <xsl:if test="boolean(key('page_break_after',@text:style-name))" > |
833 | + <pageBreak /> |
834 | + </xsl:if> |
835 | +</xsl:template> |
836 | + |
837 | +<xsl:template match="text:p/text:tab-stop"> |
838 | + <!-- simulate a tabstop --> |
839 | + <xsl:call-template name="distance_point"> |
840 | + <xsl:with-param name="background" select="key('paragraph_style',@text:style-name)/style:properties/@fo:background-color" /> |
841 | + <xsl:with-param name="tab_stop">yes</xsl:with-param> |
842 | + </xsl:call-template> |
843 | +</xsl:template> |
844 | + |
845 | +<!-- experimental - switched off |
846 | +<xsl:template match="text:h"> |
847 | + <para> |
848 | + <xsl:attribute name="style"> |
849 | + <xsl:value-of select="@text:style-name" /> |
850 | + </xsl:attribute> |
851 | + <xsl:call-template name="make_number" /> |
852 | + <xsl:apply-templates /> |
853 | + <xsl:call-template name="empty_paragraph" /> |
854 | + </para> |
855 | +</xsl:template> |
856 | + |
857 | +<xsl:template name="make_number"> |
858 | + <xsl:choose> |
859 | + <xsl:when test="@text:level='1'"> |
860 | + <xsl:number format="1. " /> |
861 | + </xsl:when> |
862 | + <xsl:when test="@text:level='2'"> |
863 | + <xsl:number count="text:h[@text:level='1']|text:h[text:level='2']" level="any" format="1.1." /> |
864 | + </xsl:when> |
865 | + </xsl:choose> |
866 | +</xsl:template> |
867 | + |
868 | +--> |
869 | + |
870 | +<xsl:template match="style:style[@style:family='paragraph']"> |
871 | + <paraStyle> |
872 | + <xsl:attribute name="name"> |
873 | + <xsl:value-of select="@style:name" /> |
874 | + </xsl:attribute> |
875 | + <xsl:call-template name="make_indent_paragraph" /> |
876 | + <xsl:call-template name="make_fontnames_paragraph" /> |
877 | + <xsl:call-template name="make_fontsize" /> |
878 | + <!--<xsl:call-template name="make_parent" /> not necessary - |
879 | + parent styles processed by PyOpenOffice --> |
880 | + <xsl:call-template name="make_alignment" /> |
881 | + <xsl:call-template name="make_background" /> |
882 | + <xsl:call-template name="make_space_beforeafter" /> |
883 | + <xsl:call-template name="make_fontcolor" /> |
884 | + </paraStyle> |
885 | +</xsl:template> |
886 | + |
887 | +<xsl:template name="make_indent_paragraph"> |
888 | + <xsl:variable name="right_indent"><xsl:value-of select="style:properties/@fo:margin-right" /></xsl:variable> |
889 | + <xsl:variable name="left_indent"><xsl:value-of select="style:properties/@fo:margin-left" /></xsl:variable> |
890 | + <xsl:if test="not($right_indent='') and boolean(style:properties/@fo:margin-right)"> |
891 | + <xsl:attribute name="rightIndent"> |
892 | + <xsl:value-of select="$right_indent" /> |
893 | + </xsl:attribute> |
894 | + </xsl:if> |
895 | + <xsl:if test="not($left_indent='') and boolean(style:properties/@fo:margin-left)"> |
896 | + <xsl:attribute name="leftIndent"> |
897 | + <xsl:value-of select="$left_indent" /> |
898 | + </xsl:attribute> |
899 | + </xsl:if> |
900 | +</xsl:template> |
901 | + |
902 | +<xsl:template name="make_background"> |
903 | + <xsl:variable name="background"> |
904 | + <xsl:value-of select="style:properties/@fo:background-color" /> |
905 | + </xsl:variable> |
906 | + <xsl:if test="not($background='') and boolean(style:properties/@fo:background-color) and starts-with($background,'#')" > |
907 | + <xsl:attribute name="backColor"> |
908 | + <xsl:value-of select="$background" /> |
909 | + </xsl:attribute> |
910 | + </xsl:if> |
911 | +</xsl:template> |
912 | + |
913 | +<xsl:template name="make_space_beforeafter"> |
914 | + <xsl:variable name="before"> |
915 | + <xsl:value-of select="style:properties/@fo:margin-top" /> |
916 | + </xsl:variable> |
917 | + <xsl:variable name="after"> |
918 | + <xsl:value-of select="style:properties/@fo:margin-bottom" /> |
919 | + </xsl:variable> |
920 | + <xsl:if test="not($before='') and boolean(style:properties/@fo:margin-top)" > |
921 | + <xsl:attribute name="spaceBefore"> |
922 | + <xsl:value-of select="$before" /> |
923 | + </xsl:attribute> |
924 | + </xsl:if> |
925 | + <xsl:if test="not($after='') and boolean(style:properties/@fo:margin-bottom)" > |
926 | + <xsl:attribute name="spaceAfter"> |
927 | + <xsl:value-of select="$after" /> |
928 | + </xsl:attribute> |
929 | + </xsl:if> |
930 | +</xsl:template> |
931 | + |
932 | +<xsl:template name="make_fontsize"> |
933 | + <xsl:variable name="fontSize"> |
934 | + <xsl:value-of select="style:properties/@fo:font-size" /> |
935 | + </xsl:variable> |
936 | + <xsl:if test="not($fontSize='') and boolean(style:properties/@fo:font-size)"> |
937 | + <xsl:attribute name="fontSize"> |
938 | + <xsl:value-of select="$fontSize" /> |
939 | + </xsl:attribute> |
940 | + <xsl:attribute name="leading"> |
941 | + <xsl:value-of select="$fontSize + floor($fontSize div 5) + 1" /> |
942 | + <!--use a standard leading related to the font size --> |
943 | + </xsl:attribute> |
944 | + </xsl:if> |
945 | +</xsl:template> |
946 | + |
947 | +<!--this template is not needed anymore for "normalized" sxw files --> |
948 | +<xsl:template name="make_parent"> |
949 | + <xsl:variable name="parent"> |
950 | + <xsl:value-of select="@style:parent-style-name" /> |
951 | + </xsl:variable> |
952 | + <xsl:if test="not($parent='') and boolean(@style:parent-style-name)"> |
953 | + <xsl:attribute name="parent"> |
954 | + <xsl:value-of select="$parent" /> |
955 | + </xsl:attribute> |
956 | + </xsl:if> |
957 | +</xsl:template> |
958 | + |
959 | +<xsl:template name="make_alignment"> |
960 | + <xsl:variable name="alignment"> |
961 | + <xsl:value-of select="style:properties/@fo:text-align" /> |
962 | + </xsl:variable> |
963 | + <xsl:if test="not($alignment='') and boolean(style:properties/@fo:text-align)"> |
964 | + <xsl:choose> |
965 | + <xsl:when test="$alignment='start'"> |
966 | + <xsl:attribute name="alignment">LEFT</xsl:attribute> |
967 | + </xsl:when> |
968 | + <xsl:when test="$alignment='center'"> |
969 | + <xsl:attribute name="alignment">CENTER</xsl:attribute> |
970 | + </xsl:when> |
971 | + <xsl:when test="$alignment='end'"> |
972 | + <xsl:attribute name="alignment">RIGHT</xsl:attribute> |
973 | + </xsl:when> |
974 | + <xsl:when test="$alignment='justify'"> |
975 | + <xsl:attribute name="alignment">JUSTIFY</xsl:attribute> |
976 | + </xsl:when> |
977 | + </xsl:choose> |
978 | + </xsl:if> |
979 | +</xsl:template> |
980 | + |
981 | +<xsl:template name="make_fontnames_paragraph"> |
982 | + <xsl:attribute name="fontName"> |
983 | + <xsl:call-template name="make_fontnames"> |
984 | + <xsl:with-param name="fontName" select="style:properties/@style:font-name" /> |
985 | + <xsl:with-param name="fontWeight" select="style:properties/@fo:font-weight" /> |
986 | + <xsl:with-param name="fontStyle" select="style:properties/@fo:font-style" /> |
987 | + </xsl:call-template> |
988 | + </xsl:attribute> |
989 | +</xsl:template> |
990 | + |
991 | +<xsl:template name="make_fontnames"> |
992 | + <!--much too verbose, needs improvement--> |
993 | +<xsl:param name="fontName" /> |
994 | +<xsl:param name="fontWeight" /> |
995 | +<xsl:param name="fontStyle" /> |
996 | +<xsl:choose> |
997 | +<xsl:when test="not($fontName='') and boolean($fontName)"> |
998 | + <xsl:choose> |
999 | + <xsl:when test="contains($fontName,'Courier')"> |
1000 | + <xsl:choose> |
1001 | + <xsl:when test="($fontWeight='bold') and ($fontStyle='italic')"> |
1002 | + <xsl:text>Courier-BoldOblique</xsl:text> |
1003 | + </xsl:when> |
1004 | + <xsl:when test="($fontWeight='bold') and not ($fontStyle='italic')"> |
1005 | + <xsl:text>Courier-Bold</xsl:text> |
1006 | + </xsl:when> |
1007 | + <xsl:when test="not($fontWeight='bold') and ($fontStyle='italic')"> |
1008 | + <xsl:text>Courier-Oblique</xsl:text> |
1009 | + </xsl:when> |
1010 | + <xsl:otherwise> |
1011 | + <xsl:text>Courier</xsl:text> |
1012 | + </xsl:otherwise> |
1013 | + </xsl:choose> |
1014 | + </xsl:when> |
1015 | + <xsl:when test="contains($fontName,'Helvetica') or contains($fontName,'Arial') or contains($fontName,'Sans')"> |
1016 | + <xsl:choose> |
1017 | + <xsl:when test="($fontWeight='bold') and ($fontStyle='italic')"> |
1018 | + <xsl:text>Helvetica-BoldOblique</xsl:text> |
1019 | + </xsl:when> |
1020 | + <xsl:when test="($fontWeight='bold') and not ($fontStyle='italic')"> |
1021 | + <xsl:text>Helvetica-Bold</xsl:text> |
1022 | + </xsl:when> |
1023 | + <xsl:when test="not($fontWeight='bold') and ($fontStyle='italic')"> |
1024 | + <xsl:text>Helvetica-Oblique</xsl:text> |
1025 | + </xsl:when> |
1026 | + <xsl:otherwise> |
1027 | + <xsl:text>Helvetica</xsl:text> |
1028 | + </xsl:otherwise> |
1029 | + </xsl:choose> |
1030 | + </xsl:when> |
1031 | + <xsl:otherwise> |
1032 | + <xsl:choose> |
1033 | + <xsl:when test="($fontWeight='bold') and ($fontStyle='italic')"> |
1034 | + <xsl:text>Times-BoldItalic</xsl:text> |
1035 | + </xsl:when> |
1036 | + <xsl:when test="($fontWeight='bold') and not ($fontStyle='italic')"> |
1037 | + <xsl:text>Times-Bold</xsl:text> |
1038 | + </xsl:when> |
1039 | + <xsl:when test="not($fontWeight='bold') and ($fontStyle='italic')"> |
1040 | + <xsl:text>Times-Italic</xsl:text> |
1041 | + </xsl:when> |
1042 | + <xsl:otherwise> |
1043 | + <xsl:text>Times-Roman</xsl:text> |
1044 | + </xsl:otherwise> |
1045 | + </xsl:choose> |
1046 | + </xsl:otherwise> |
1047 | + </xsl:choose> |
1048 | +</xsl:when> |
1049 | +<xsl:otherwise> |
1050 | + <!--Use this as default --> |
1051 | + <xsl:text>Times-Roman</xsl:text> |
1052 | +</xsl:otherwise> |
1053 | +</xsl:choose> |
1054 | +</xsl:template> |
1055 | +<xsl:template name="make_fontcolor"> |
1056 | + <xsl:variable name="textColor"> |
1057 | + <xsl:value-of select="style:properties/@fo:color"/> |
1058 | + </xsl:variable> |
1059 | + <xsl:if test="not($textColor='') and boolean(style:properties/@fo:color)"> |
1060 | + <xsl:attribute name="textColor"> |
1061 | + <xsl:value-of select="$textColor" /> |
1062 | + </xsl:attribute> |
1063 | + </xsl:if> |
1064 | +</xsl:template> |
1065 | + |
1066 | +<!-- |
1067 | +This stylesheet is part of: |
1068 | +PyOpenOffice Version 0.4 |
1069 | +Copyright (C) 2005: Martin Simon |
1070 | +Homepage: www.bezirksreiter.de |
1071 | + |
1072 | +GNU LESSER GENERAL PUBLIC LICENSE Version 2.1, February 1999 |
1073 | +--> |
1074 | + |
1075 | +</xsl:stylesheet> |
1076 | + |
1077 | + |
1078 | |
1079 | === added file 'shipping_api_ups/report/summary_report.py' |
1080 | --- shipping_api_ups/report/summary_report.py 1970-01-01 00:00:00 +0000 |
1081 | +++ shipping_api_ups/report/summary_report.py 2011-10-06 16:08:52 +0000 |
1082 | @@ -0,0 +1,55 @@ |
1083 | +# -*- coding: utf-8 -*- |
1084 | +############################################################################## |
1085 | +# |
1086 | +# OpenERP, Open Source Management Solution |
1087 | +# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>). |
1088 | +# |
1089 | +# This program is free software: you can redistribute it and/or modify |
1090 | +# it under the terms of the GNU Affero General Public License as |
1091 | +# published by the Free Software Foundation, either version 3 of the |
1092 | +# License, or (at your option) any later version. |
1093 | +# |
1094 | +# This program is distributed in the hope that it will be useful, |
1095 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
1096 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
1097 | +# GNU Affero General Public License for more details. |
1098 | +# |
1099 | +# You should have received a copy of the GNU Affero General Public License |
1100 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. |
1101 | +# |
1102 | +############################################################################## |
1103 | + |
1104 | +import time |
1105 | +from report import report_sxw |
1106 | +import pooler |
1107 | + |
1108 | + |
1109 | +class summary_report_print(report_sxw.rml_parse): |
1110 | + def __init__(self, cr, uid, name, context): |
1111 | + super(summary_report_print, self).__init__(cr, uid, name, context) |
1112 | + db_pool = pooler.get_pool(self.cr.dbname) |
1113 | + self.localcontext.update({ |
1114 | + 'time': time, |
1115 | + 'get_total':self.get_total, |
1116 | + 'get_items':self.get_items, |
1117 | + }) |
1118 | + def get_total(self): |
1119 | + ship_ids=pooler.get_pool(self.cr.dbname).get('shipping.move').search(self.cr,self.uid,[('state','=','ready_pick')]) |
1120 | + return str(len(ship_ids)) |
1121 | + def get_items(self): |
1122 | + ret = {} |
1123 | + ship_ids=pooler.get_pool(self.cr.dbname).get('shipping.move').search(self.cr,self.uid,[('state','=','ready_pick')]) |
1124 | + if ship_ids: |
1125 | + for ship_id in pooler.get_pool(self.cr.dbname).get('shipping.move').browse(self.cr,self.uid,ship_ids): |
1126 | + key = ship_id.service and ship_id.service.description or '' |
1127 | + ret[key] = 1 + ret.get(key,0) |
1128 | + return ret.items() |
1129 | + |
1130 | + |
1131 | +report_sxw.report_sxw( |
1132 | + 'report.summary_report_print', |
1133 | + 'shipping.move', |
1134 | + 'addons/shipping_api/report/summary_report.rml', |
1135 | + parser=summary_report_print |
1136 | +) |
1137 | + |
1138 | |
1139 | === added file 'shipping_api_ups/report/summary_report.rml' |
1140 | --- shipping_api_ups/report/summary_report.rml 1970-01-01 00:00:00 +0000 |
1141 | +++ shipping_api_ups/report/summary_report.rml 2011-10-06 16:08:52 +0000 |
1142 | @@ -0,0 +1,97 @@ |
1143 | +<?xml version="1.0"?> |
1144 | +<document filename="test.pdf"> |
1145 | + <template pageSize="(595.0,842.0)" title="Test" author="Martin Simon" allowSplitting="20"> |
1146 | + <pageTemplate id="first"> |
1147 | + <frame id="first" x1="55.0" y1="0.0" width="495" height="786"/> |
1148 | + </pageTemplate> |
1149 | + </template> |
1150 | + <stylesheet> |
1151 | + <blockTableStyle id="Standard_Outline"> |
1152 | + <blockAlignment value="LEFT"/> |
1153 | + <blockValign value="TOP"/> |
1154 | + </blockTableStyle> |
1155 | + <blockTableStyle id="Table2"> |
1156 | + <blockAlignment value="LEFT"/> |
1157 | + <blockValign value="TOP"/> |
1158 | + <lineStyle kind="LINEBEFORE" colorName="#000000" start="0,0" stop="0,-1"/> |
1159 | + <lineStyle kind="LINEABOVE" colorName="#000000" start="0,0" stop="0,0"/> |
1160 | + <lineStyle kind="LINEBELOW" colorName="#000000" start="0,-1" stop="0,-1"/> |
1161 | + <lineStyle kind="LINEBEFORE" colorName="#000000" start="1,0" stop="1,-1"/> |
1162 | + <lineStyle kind="LINEAFTER" colorName="#000000" start="1,0" stop="1,-1"/> |
1163 | + <lineStyle kind="LINEABOVE" colorName="#000000" start="1,0" stop="1,0"/> |
1164 | + <lineStyle kind="LINEBELOW" colorName="#000000" start="1,-1" stop="1,-1"/> |
1165 | + </blockTableStyle> |
1166 | + <blockTableStyle id="Table4"> |
1167 | + <blockAlignment value="LEFT"/> |
1168 | + <blockValign value="TOP"/> |
1169 | + <lineStyle kind="LINEBEFORE" colorName="#000000" start="0,0" stop="0,-1"/> |
1170 | + <lineStyle kind="LINEABOVE" colorName="#000000" start="0,0" stop="0,0"/> |
1171 | + <lineStyle kind="LINEBELOW" colorName="#000000" start="0,-1" stop="0,-1"/> |
1172 | + <lineStyle kind="LINEBEFORE" colorName="#000000" start="1,0" stop="1,-1"/> |
1173 | + <lineStyle kind="LINEAFTER" colorName="#000000" start="1,0" stop="1,-1"/> |
1174 | + <lineStyle kind="LINEABOVE" colorName="#000000" start="1,0" stop="1,0"/> |
1175 | + <lineStyle kind="LINEBELOW" colorName="#000000" start="1,-1" stop="1,-1"/> |
1176 | + </blockTableStyle> |
1177 | + <initialize> |
1178 | + <paraStyle name="all" alignment="justify"/> |
1179 | + </initialize> |
1180 | + <paraStyle name="P1" rightIndent="22.0" leftIndent="20.0" fontName="Helvetica-Bold" fontSize="14.0" leading="17" alignment="CENTER"/> |
1181 | + <paraStyle name="P2" rightIndent="22.0" leftIndent="20.0" fontName="Helvetica-Bold" fontSize="15.0" leading="19"/> |
1182 | + <paraStyle name="P3" rightIndent="22.0" leftIndent="20.0" fontName="Helvetica" fontSize="11.0" leading="14"/> |
1183 | + <paraStyle name="P4" fontName="Helvetica" fontSize="15.0" leading="19"/> |
1184 | + <paraStyle name="P5" rightIndent="22.0" leftIndent="0.0" fontName="Helvetica" fontSize="11.0" leading="14"/> |
1185 | + <paraStyle name="P6" rightIndent="22.0" leftIndent="0.0" fontName="Helvetica-Bold" fontSize="11.0" leading="14"/> |
1186 | + <paraStyle name="P7" rightIndent="22.0" leftIndent="0.0" fontName="Helvetica-Bold" fontSize="15.0" leading="19"/> |
1187 | + <paraStyle name="P8" rightIndent="22.0" leftIndent="0.0" fontName="Helvetica"/> |
1188 | + <paraStyle name="Standard" fontName="Helvetica"/> |
1189 | + <paraStyle name="Heading" fontName="Helvetica" fontSize="14.0" leading="17" spaceBefore="12.0" spaceAfter="6.0"/> |
1190 | + <paraStyle name="Text body" fontName="Helvetica" spaceBefore="0.0" spaceAfter="6.0"/> |
1191 | + <paraStyle name="List" fontName="Helvetica" spaceBefore="0.0" spaceAfter="6.0"/> |
1192 | + <paraStyle name="Caption" fontName="Helvetica" fontSize="12.0" leading="15" spaceBefore="6.0" spaceAfter="6.0"/> |
1193 | + <paraStyle name="Index" fontName="Helvetica"/> |
1194 | + <paraStyle name="Table Contents" fontName="Helvetica"/> |
1195 | + <paraStyle name="Table Heading" fontName="Helvetica" alignment="CENTER"/> |
1196 | + <images/> |
1197 | + </stylesheet> |
1198 | + <story> |
1199 | + <para style="P1">Shipping Summary Report</para> |
1200 | + <para style="P3"> |
1201 | + <font color="white"> </font> |
1202 | + </para> |
1203 | + <para style="P5"> |
1204 | + <font color="white"> </font> |
1205 | + </para> |
1206 | + <para style="P6">Date : [[time.strftime("%b %d, %Y")]]</para> |
1207 | + <para style="P6">Total number of packages : [[get_total()]]</para> |
1208 | + <para style="P7"> |
1209 | + <font color="white"> </font> |
1210 | + </para> |
1211 | + <blockTable colWidths="248.0,248.0" style="Table2"> |
1212 | + <tr> |
1213 | + <td> |
1214 | + <para style="P2">Shipping Method</para> |
1215 | + </td> |
1216 | + <td> |
1217 | + <para style="P2">Count</para> |
1218 | + </td> |
1219 | + </tr> |
1220 | + </blockTable> |
1221 | + <blockTable colWidths="248.0,248.0" style="Table4"> |
1222 | + <tr> |
1223 | + <td> |
1224 | + <para style="P4">[[not get_items() and removeParentNode('blockTable')]][[repeatIn(get_items(),'p')]][[ p[0] ]]</para> |
1225 | + </td> |
1226 | + <td> |
1227 | + <para style="P4">[[ p[1] ]]</para> |
1228 | + </td> |
1229 | + </tr> |
1230 | + </blockTable> |
1231 | + <para style="P7"> |
1232 | + <font color="white"> </font> |
1233 | + </para> |
1234 | + <para style="P8"> |
1235 | + <font color="white"> </font> |
1236 | + </para> |
1237 | + </story> |
1238 | +</document> |
1239 | + |
1240 | |
1241 | === added file 'shipping_api_ups/report/summary_report.sxw' |
1242 | Binary files shipping_api_ups/report/summary_report.sxw 1970-01-01 00:00:00 +0000 and shipping_api_ups/report/summary_report.sxw 2011-10-06 16:08:52 +0000 differ |
1243 | === added file 'shipping_api_ups/report/tiny_sxw2rml.py' |
1244 | --- shipping_api_ups/report/tiny_sxw2rml.py 1970-01-01 00:00:00 +0000 |
1245 | +++ shipping_api_ups/report/tiny_sxw2rml.py 2011-10-06 16:08:52 +0000 |
1246 | @@ -0,0 +1,377 @@ |
1247 | +#!/usr/bin/python |
1248 | +# -*- encoding: utf-8 -*- |
1249 | +############################################################################## |
1250 | +# |
1251 | +# Copyright (c): |
1252 | +# |
1253 | +# 2005 pyopenoffice.py Martin Simon (http://www.bezirksreiter.de) |
1254 | +# 2005 Fabien Pinckaers, TINY SPRL. (http://tiny.be) |
1255 | +# |
1256 | +# WARNING: This program as such is intended to be used by professional |
1257 | +# programmers who take the whole responsability of assessing all potential |
1258 | +# consequences resulting from its eventual inadequacies and bugs |
1259 | +# End users who are looking for a ready-to-use solution with commercial |
1260 | +# garantees and support are strongly adviced to contact a Free Software |
1261 | +# Service Company |
1262 | +# |
1263 | +# This program is Free Software; you can redistribute it and/or |
1264 | +# modify it under the terms of the GNU General Public License |
1265 | +# as published by the Free Software Foundation; either version 2 |
1266 | +# of the License, or (at your option) any later version. |
1267 | +# |
1268 | +# This program is distributed in the hope that it will be useful, |
1269 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
1270 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
1271 | +# GNU General Public License for more details. |
1272 | +# |
1273 | +# You should have received a copy of the GNU General Public License |
1274 | +# along with this program; if not, write to the Free Software |
1275 | +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
1276 | +# |
1277 | +############################################################################## |
1278 | + |
1279 | +""" |
1280 | +Tiny SXW2RML - The Open ERP's report engine |
1281 | + |
1282 | +Tiny SXW2RMLis part of the Tiny report project. |
1283 | +Tiny Report is a module that allows you to render high quality PDF document |
1284 | +from an OpenOffice template (.sxw) and any relationnal database. |
1285 | + |
1286 | +The whole source code is distributed under the terms of the |
1287 | +GNU Public Licence. |
1288 | + |
1289 | +(c) 2005 pyopenoffice.py Martin Simon (http://www.bezirksreiter.de) |
1290 | +(c) 2005-TODAY, Fabien Pinckaers - Tiny sprl |
1291 | +""" |
1292 | +__version__ = '0.9' |
1293 | + |
1294 | + |
1295 | +import re |
1296 | +import string |
1297 | +import os |
1298 | +import zipfile |
1299 | +import xml.dom.minidom |
1300 | +from reportlab.lib.units import toLength |
1301 | +import base64 |
1302 | + |
1303 | +class DomApiGeneral: |
1304 | + """General DOM API utilities.""" |
1305 | + def __init__(self,content_string="",file=""): |
1306 | + self.content_string = content_string |
1307 | + self.re_digits = re.compile(r"(.*?\d)(pt|cm|mm|inch|in)") |
1308 | + |
1309 | + def _unitTuple(self,string): |
1310 | + """Split values and units to a tuple.""" |
1311 | + temp = self.re_digits.findall(string) |
1312 | + if not temp: |
1313 | + return (string,"") |
1314 | + else: |
1315 | + return (temp[0]) |
1316 | + |
1317 | + def stringPercentToFloat(self,string): |
1318 | + temp = string.replace("""%""","") |
1319 | + return float(temp)/100 |
1320 | + |
1321 | + def findChildrenByName(self,parent,name,attr_dict={}): |
1322 | + """Helper functions. Does not work recursively. |
1323 | + Optional: also test for certain attribute/value pairs.""" |
1324 | + children = [] |
1325 | + for c in parent.childNodes: |
1326 | + if c.nodeType == c.ELEMENT_NODE and c.nodeName == name: |
1327 | + children.append(c) |
1328 | + if attr_dict == {}: |
1329 | + return children |
1330 | + else: |
1331 | + return self._selectForAttributes(nodelist=children,attr_dict=attr_dict) |
1332 | + |
1333 | + def _selectForAttributes(self,nodelist,attr_dict): |
1334 | + "Helper function.""" |
1335 | + selected_nodes = [] |
1336 | + for n in nodelist: |
1337 | + check = 1 |
1338 | + for a in attr_dict.keys(): |
1339 | + if n.getAttribute(a) != attr_dict[a]: |
1340 | + # at least one incorrect attribute value? |
1341 | + check = 0 |
1342 | + if check: |
1343 | + selected_nodes.append(n) |
1344 | + return selected_nodes |
1345 | + |
1346 | + def _stringToTuple(self,s): |
1347 | + """Helper function.""" |
1348 | + try: |
1349 | + temp = string.split(s,",") |
1350 | + return int(temp[0]),int(temp[1]) |
1351 | + except: |
1352 | + return None |
1353 | + |
1354 | + def _tupleToString(self,t): |
1355 | + try: |
1356 | + return self.openOfficeStringUtf8("%s,%s" % (t[0],t[1])) |
1357 | + except: |
1358 | + return None |
1359 | + |
1360 | + def _lengthToFloat(self,value): |
1361 | + v = value |
1362 | + if not self.re_digits.search(v): |
1363 | + return v |
1364 | + try: |
1365 | + if v[-4:] == "inch": |
1366 | + # OO files use "inch" instead of "in" in Reportlab units |
1367 | + v = v[:-2] |
1368 | + except: |
1369 | + pass |
1370 | + try: |
1371 | + c = round(toLength(v)) |
1372 | + return c |
1373 | + except: |
1374 | + return v |
1375 | + |
1376 | + def openOfficeStringUtf8(self,string): |
1377 | + if type(string) == unicode: |
1378 | + return string.encode("utf-8") |
1379 | + tempstring = unicode(string,"cp1252").encode("utf-8") |
1380 | + return tempstring |
1381 | + |
1382 | +class DomApi(DomApiGeneral): |
1383 | + """This class provides a DOM-API for XML-Files from an SXW-Archive.""" |
1384 | + def __init__(self,xml_content,xml_styles): |
1385 | + DomApiGeneral.__init__(self) |
1386 | + self.content_dom = xml.dom.minidom.parseString(xml_content) |
1387 | + self.styles_dom = xml.dom.minidom.parseString(xml_styles) |
1388 | + body = self.content_dom.getElementsByTagName("office:body") |
1389 | + self.body = body and body[0] |
1390 | + |
1391 | + # TODO: |
1392 | + self.style_dict = {} |
1393 | + self.style_properties_dict = {} |
1394 | + |
1395 | + # ******** always use the following order: |
1396 | + self.buildStyleDict() |
1397 | + self.buildStylePropertiesDict() |
1398 | + if self.styles_dom.getElementsByTagName("style:page-master").__len__()<>0: |
1399 | + self.page_master = self.styles_dom.getElementsByTagName("style:page-master")[0] |
1400 | + if self.styles_dom.getElementsByTagName("style:page-layout").__len__()<>0 : |
1401 | + self.page_master = self.styles_dom.getElementsByTagName("style:page-layout")[0] |
1402 | + self.document = self.content_dom.getElementsByTagName("office:document-content")[0] |
1403 | + |
1404 | + def buildStylePropertiesDict(self): |
1405 | + for s in self.style_dict.keys(): |
1406 | + self.style_properties_dict[s] = self.getStylePropertiesDict(s) |
1407 | + |
1408 | + def updateWithPercents(self,dict,updatedict): |
1409 | + """Sometimes you find values like "115%" in the style hierarchy.""" |
1410 | + if not updatedict: |
1411 | + # no style hierarchies for this style? => |
1412 | + return |
1413 | + new_updatedict = copy.copy(updatedict) |
1414 | + for u in new_updatedict.keys(): |
1415 | + try: |
1416 | + if new_updatedict[u].find("""%""") != -1 and dict.has_key(u): |
1417 | + number = float(self.re_digits.search(dict[u]).group(1)) |
1418 | + unit = self.re_digits.search(dict[u]).group(2) |
1419 | + new_number = self.stringPercentToFloat(new_updatedict[u]) * number |
1420 | + if unit == "pt": |
1421 | + new_number = int(new_number) |
1422 | + # no floats allowed for "pt" |
1423 | + # OOo just takes the int, does not round (try it out!) |
1424 | + new_updatedict[u] = "%s%s" % (new_number,unit) |
1425 | + else: |
1426 | + dict[u] = new_updatedict[u] |
1427 | + except: |
1428 | + dict[u] = new_updatedict[u] |
1429 | + dict.update(new_updatedict) |
1430 | + |
1431 | + def normalizeStyleProperties(self): |
1432 | + """Transfer all style:style-properties attributes from the |
1433 | + self.style_properties_hierarchical dict to the automatic-styles |
1434 | + from content.xml. Use this function to preprocess content.xml for |
1435 | + XSLT transformations etc.Do not try to implement this function |
1436 | + with XSlT - believe me, it's a terrible task...""" |
1437 | + styles_styles = self.styles_dom.getElementsByTagName("style:style") |
1438 | + automatic_styles = self.content_dom.getElementsByTagName("office:automatic-styles")[0] |
1439 | + for s in styles_styles: |
1440 | + automatic_styles.appendChild(s.cloneNode(deep=1)) |
1441 | + content_styles = self.content_dom.getElementsByTagName("style:style") |
1442 | + # these are the content_styles with styles_styles added!!! |
1443 | + for s in content_styles: |
1444 | + c = self.findChildrenByName(s,"style:properties") |
1445 | + if c == []: |
1446 | + # some derived automatic styles do not have "style:properties": |
1447 | + temp = self.content_dom.createElement("style:properties") |
1448 | + s.appendChild(temp) |
1449 | + c = self.findChildrenByName(s,"style:properties") |
1450 | + c = c[0] |
1451 | + dict = self.style_properties_dict[(s.getAttribute("style:name")).encode("utf-8")] or {} |
1452 | + for attribute in dict.keys(): |
1453 | + c.setAttribute(self.openOfficeStringUtf8(attribute),self.openOfficeStringUtf8(dict[attribute])) |
1454 | + |
1455 | + def transferStylesXml(self): |
1456 | + """Transfer certain sub-trees from styles.xml to the normalized content.xml |
1457 | + (see above). It is not necessary to do this - for example - with paragraph styles. |
1458 | + the "normalized" style properties contain all information needed for |
1459 | + further processing.""" |
1460 | + # TODO: What about table styles etc.? |
1461 | + outline_styles = self.styles_dom.getElementsByTagName("text:outline-style") |
1462 | + t = self.content_dom.createElement("transferredfromstylesxml") |
1463 | + self.document.insertBefore(t,self.body) |
1464 | + t_new = self.body.previousSibling |
1465 | + try: |
1466 | + page_master = self.page_master |
1467 | + t_new.appendChild(page_master.cloneNode(deep=1)) |
1468 | + t_new.appendChild(outline_styles[0].cloneNode(deep=1)) |
1469 | + except: |
1470 | + pass |
1471 | + |
1472 | + def normalizeLength(self): |
1473 | + """Normalize all lengthes to floats (i.e: 1 inch = 72). |
1474 | + Always use this after "normalizeContent" and "transferStyles"!""" |
1475 | + # TODO: The complex attributes of table cell styles are not transferred yet. |
1476 | + #all_styles = self.content_dom.getElementsByTagName("style:properties") |
1477 | + #all_styles += self.content_dom.getElementsByTagName("draw:image") |
1478 | + all_styles = self.content_dom.getElementsByTagName("*") |
1479 | + for s in all_styles: |
1480 | + for x in s._attrs.keys(): |
1481 | + v = s.getAttribute(x) |
1482 | + s.setAttribute(x,"%s" % self._lengthToFloat(v)) |
1483 | + # convert float to string first! |
1484 | + |
1485 | + def normalizeTableColumns(self): |
1486 | + """Handle this strange table:number-columns-repeated attribute.""" |
1487 | + columns = self.content_dom.getElementsByTagName("table:table-column") |
1488 | + for c in columns: |
1489 | + if c.hasAttribute("table:number-columns-repeated"): |
1490 | + number = int(c.getAttribute("table:number-columns-repeated")) |
1491 | + c.removeAttribute("table:number-columns-repeated") |
1492 | + for i in range(number-1): |
1493 | + (c.parentNode).insertBefore(c.cloneNode(deep=1),c) |
1494 | + |
1495 | + def buildStyleDict(self): |
1496 | + """Store all style:style-nodes from content.xml and styles.xml in self.style_dict. |
1497 | + Caution: in this dict the nodes from two dom apis are merged!""" |
1498 | + for st in (self.styles_dom,self.content_dom): |
1499 | + for s in st.getElementsByTagName("style:style"): |
1500 | + name = s.getAttribute("style:name").encode("utf-8") |
1501 | + self.style_dict[name] = s |
1502 | + return True |
1503 | + |
1504 | + def toxml(self): |
1505 | + return self.content_dom.toxml(encoding="utf-8") |
1506 | + |
1507 | + def getStylePropertiesDict(self,style_name): |
1508 | + res = {} |
1509 | + |
1510 | + if self.style_dict[style_name].hasAttribute("style:parent-style-name"): |
1511 | + parent = self.style_dict[style_name].getAttribute("style:parent-style-name").encode("utf-8") |
1512 | + res = self.getStylePropertiesDict(parent) |
1513 | + |
1514 | + childs = self.style_dict[style_name].childNodes |
1515 | + for c in childs: |
1516 | + if c.nodeType == c.ELEMENT_NODE and c.nodeName.find("properties")>0 : |
1517 | + for attr in c._attrs.keys(): |
1518 | + res[attr] = c.getAttribute(attr).encode("utf-8") |
1519 | + return res |
1520 | + |
1521 | +class PyOpenOffice(object): |
1522 | + """This is the main class which provides all functionality.""" |
1523 | + def __init__(self, path='.', save_pict=False): |
1524 | + self.path = path |
1525 | + self.save_pict = save_pict |
1526 | + self.images = {} |
1527 | + |
1528 | + def oo_read(self,fname): |
1529 | + z = zipfile.ZipFile(fname,"r") |
1530 | + content = z.read('content.xml') |
1531 | + style = z.read('styles.xml') |
1532 | + all = z.namelist() |
1533 | + for a in all: |
1534 | + if a[:9]=='Pictures/' and len(a)>10: |
1535 | + pic_content = z.read(a) |
1536 | + self.images[a[9:]] = pic_content |
1537 | + if self.save_pict: |
1538 | + f=open(os.path.join(self.path, os.path.basename(a)),"wb") |
1539 | + f.write(pic_content) |
1540 | + f.close() |
1541 | + z.close() |
1542 | + return content,style |
1543 | + |
1544 | + def oo_replace(self,content): |
1545 | + regex = [ |
1546 | + (r"<para[^>]*/>", ""), |
1547 | + #(r"<text:ordered-list.*?>(.*?)</text:ordered-list>", "$1"), |
1548 | + #(r"<text:unordered-list.*?>(.*?)</text:unordered-list>", "$1"), |
1549 | + (r"<para(.*)>(.*?)<text:line-break[^>]*/>", "<para$1>$2</para><para$1>"), |
1550 | + ] |
1551 | + for key,val in regex: |
1552 | + content = re.sub(key, val, content) |
1553 | + return content |
1554 | + |
1555 | + def unpackNormalize(self,sourcefile): |
1556 | + c,s = self.oo_read(sourcefile) |
1557 | + c = self.oo_replace(c) |
1558 | + dom = DomApi(c,s) |
1559 | + dom.normalizeStyleProperties() |
1560 | + dom.transferStylesXml() |
1561 | + dom.normalizeLength() |
1562 | + dom.normalizeTableColumns() |
1563 | + new_c = dom.toxml() |
1564 | + return new_c |
1565 | + |
1566 | +def sxw2rml(sxw_file, xsl, output='.', save_pict=False): |
1567 | + from lxml import etree |
1568 | + from StringIO import StringIO |
1569 | + |
1570 | + tool = PyOpenOffice(output, save_pict = save_pict) |
1571 | + res = tool.unpackNormalize(sxw_file) |
1572 | + |
1573 | + f = StringIO(xsl) |
1574 | + styledoc = etree.parse(f) |
1575 | + style = etree.XSLT(styledoc) |
1576 | + |
1577 | + f = StringIO(res) |
1578 | + doc = etree.parse(f) |
1579 | + result = style(doc) |
1580 | + root = etree.XPathEvaluator(result)("/document/stylesheet") |
1581 | + |
1582 | + if root: |
1583 | + root=root[0] |
1584 | + images = etree.Element("images") |
1585 | + for img in tool.images: |
1586 | + node = etree.Element('image', name=img) |
1587 | + node.text = base64.encodestring(tool.images[img]) |
1588 | + images.append(node) |
1589 | + root.append(images) |
1590 | + |
1591 | + try: |
1592 | + xml = str(result) |
1593 | + return xml |
1594 | + except: |
1595 | + return result |
1596 | + |
1597 | +if __name__ == "__main__": |
1598 | + import optparse |
1599 | + parser = optparse.OptionParser( |
1600 | + version="Tiny Report v%s" % __version__, |
1601 | + usage = 'tiny_sxw2rml.py [options] file.sxw') |
1602 | + parser.add_option("-v", "--verbose", default=False, dest="verbose", help="enable basic debugging") |
1603 | + parser.add_option("-o", "--output", dest="output", default='.', help="directory of image output") |
1604 | + (opt, args) = parser.parse_args() |
1605 | + if len(args) != 1: |
1606 | + parser.error("incorrect number of arguments") |
1607 | + |
1608 | + import sys |
1609 | + import StringIO |
1610 | + |
1611 | + fname = sys.argv[1] |
1612 | + f = fname |
1613 | + xsl_file = 'normalized_oo2rml.xsl' |
1614 | + z = zipfile.ZipFile(fname,"r") |
1615 | + mimetype = z.read('mimetype') |
1616 | + if mimetype.split('/')[-1] == 'vnd.oasis.opendocument.text' : |
1617 | + xsl_file = 'normalized_odt2rml.xsl' |
1618 | + xsl = file(os.path.join(os.getcwd(), os.path.dirname(sys.argv[0]), xsl_file)).read() |
1619 | + result = sxw2rml(f, xsl, output=opt.output, save_pict=False) |
1620 | + |
1621 | + print result |
1622 | +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: |
1623 | + |
1624 | |
1625 | === added file 'shipping_api_ups/sale.py' |
1626 | --- shipping_api_ups/sale.py 1970-01-01 00:00:00 +0000 |
1627 | +++ shipping_api_ups/sale.py 2011-10-06 16:08:52 +0000 |
1628 | @@ -0,0 +1,34 @@ |
1629 | +# -*- coding: utf-8 -*- |
1630 | +############################################################################## |
1631 | +# |
1632 | +# OpenERP, Open Source Management Solution |
1633 | +# Copyright (C) 2011 NovaPoint Group LLC (<http://www.novapointgroup.com>) |
1634 | +# Copyright (C) 2004-2010 OpenERP SA (<http://www.openerp.com>) |
1635 | +# |
1636 | +# This program is free software: you can redistribute it and/or modify |
1637 | +# it under the terms of the GNU General Public License as published by |
1638 | +# the Free Software Foundation, either version 3 of the License, or |
1639 | +# (at your option) any later version. |
1640 | +# |
1641 | +# This program is distributed in the hope that it will be useful, |
1642 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
1643 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
1644 | +# GNU General Public License for more details. |
1645 | +# |
1646 | +# You should have received a copy of the GNU General Public License |
1647 | +# along with this program. If not, see <http://www.gnu.org/licenses/> |
1648 | +# |
1649 | +############################################################################## |
1650 | +from osv import fields,osv |
1651 | + |
1652 | +class sale_order(osv.osv): |
1653 | + _inherit="sale.order" |
1654 | + |
1655 | + _columns= { |
1656 | + |
1657 | + 'payment_method':fields.selection([('cc_pre_auth','Credit Card – PreAuthorized'), |
1658 | + ('invoice','Invoice'), |
1659 | + ('cod','COD'), |
1660 | + ('p_i_a','Pay In Advance'),],'Payment Method'), |
1661 | + } |
1662 | +sale_order() |
1663 | \ No newline at end of file |
1664 | |
1665 | === added file 'shipping_api_ups/sale_view.xml' |
1666 | --- shipping_api_ups/sale_view.xml 1970-01-01 00:00:00 +0000 |
1667 | +++ shipping_api_ups/sale_view.xml 2011-10-06 16:08:52 +0000 |
1668 | @@ -0,0 +1,16 @@ |
1669 | +<?xml version="1.0" encoding="UTF-8"?> |
1670 | +<openerp> |
1671 | + <data> |
1672 | + <record id="sale_order_changes_for_shipping" model="ir.ui.view"> |
1673 | + <field name="name">sale_order_changes_for_shipping</field> |
1674 | + <field name="model">sale.order</field> |
1675 | + <field name="type">form</field> |
1676 | + <field name="inherit_id" ref="sale.view_order_form"/> |
1677 | + <field name="arch" type="xml"> |
1678 | + <xpath expr="//field[@name='pricelist_id']" position="after"> |
1679 | + <field name="payment_method" invisible="1"/> |
1680 | + </xpath> |
1681 | + </field> |
1682 | + </record> |
1683 | + </data> |
1684 | +</openerp> |
1685 | \ No newline at end of file |
1686 | |
1687 | === added directory 'shipping_api_ups/security' |
1688 | === added file 'shipping_api_ups/security/ir.model.access.csv' |
1689 | --- shipping_api_ups/security/ir.model.access.csv 1970-01-01 00:00:00 +0000 |
1690 | +++ shipping_api_ups/security/ir.model.access.csv 2011-10-06 16:08:52 +0000 |
1691 | @@ -0,0 +1,5 @@ |
1692 | +"id","name","model_id:id","group_id:id","perm_read","perm_write","perm_create","perm_unlink" |
1693 | +"security_ups_account_shipping_user","security.ups.account.shipping.user","model_ups_account_shipping","base.group_sale_salesman",1,1,1,0 |
1694 | +"security_ups_account_shipping_manager","security.ups.account.shipping.manager","model_ups_account_shipping","base.group_erp_manager",1,1,1,1 |
1695 | +"security_ups_shipping_service_type_user","security.ups.shipping.service.type.user","model_ups_shipping_service_type","base.group_sale_salesman",1,1,1,0 |
1696 | +"security_ups_shipping_service_type_manager","security.ups.shipping.service.type.manager","model_ups_shipping_service_type","base.group_erp_manager",1,1,1,1 |
1697 | \ No newline at end of file |
1698 | |
1699 | === added file 'shipping_api_ups/shipping_report.xml' |
1700 | --- shipping_api_ups/shipping_report.xml 1970-01-01 00:00:00 +0000 |
1701 | +++ shipping_api_ups/shipping_report.xml 2011-10-06 16:08:52 +0000 |
1702 | @@ -0,0 +1,44 @@ |
1703 | +<?xml version="1.0"?> |
1704 | +<openerp> |
1705 | + <data> |
1706 | + <report id="ship_label_print" |
1707 | + string="Print Label" |
1708 | + model="stock.packages" |
1709 | + name="ship.label.print" |
1710 | + rml="addons/shipping_api_ups/report/label_print.rml" |
1711 | + menu="False" |
1712 | + auto="False"/> |
1713 | + <report id="ship_log_label_print" |
1714 | + string="Print Label" |
1715 | + model="shipping.move" |
1716 | + name="ship.log.label.print" |
1717 | + rml="addons/shipping_api_ups/report/label_print.rml" |
1718 | + menu="False" |
1719 | + auto="False"/> |
1720 | + <report id="quick_ship_label_print" |
1721 | + string="Print Label" |
1722 | + model="quick.ship" |
1723 | + name="quick.ship.label.print" |
1724 | + rml="addons/shipping_api_ups/report/label_print.rml" |
1725 | + menu="False" |
1726 | + auto="False"/> |
1727 | + <report id="multiple_label_print" |
1728 | + string="Print Label" |
1729 | + model="stock.picking" |
1730 | + name="multiple.label.print" |
1731 | + rml="addons/shipping_api_ups/report/multiple_label_print.rml" |
1732 | + menu="False" |
1733 | + auto="False"/> |
1734 | + |
1735 | + |
1736 | + |
1737 | + <report id="summary_report_print" |
1738 | + string="Summary Report" |
1739 | + model="shipping.move" |
1740 | + name="summary_report_print" |
1741 | + rml="addons/shipping_api_ups/report/summary_report.rml" |
1742 | + auto="False" |
1743 | + header = "False" |
1744 | + menu="True"/> |
1745 | + </data> |
1746 | +</openerp> |
1747 | |
1748 | === added file 'shipping_api_ups/stock.py' |
1749 | --- shipping_api_ups/stock.py 1970-01-01 00:00:00 +0000 |
1750 | +++ shipping_api_ups/stock.py 2011-10-06 16:08:52 +0000 |
1751 | @@ -0,0 +1,2921 @@ |
1752 | +# -*- coding: utf-8 -*- |
1753 | +############################################################################## |
1754 | +# |
1755 | +# OpenERP, Open Source Management Solution |
1756 | +# Copyright (C) 2011 NovaPoint Group LLC (<http://www.novapointgroup.com>) |
1757 | +# Copyright (C) 2004-2010 OpenERP SA (<http://www.openerp.com>) |
1758 | +# |
1759 | +# This program is free software: you can redistribute it and/or modify |
1760 | +# it under the terms of the GNU General Public License as published by |
1761 | +# the Free Software Foundation, either version 3 of the License, or |
1762 | +# (at your option) any later version. |
1763 | +# |
1764 | +# This program is distributed in the hope that it will be useful, |
1765 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
1766 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
1767 | +# GNU General Public License for more details. |
1768 | +# |
1769 | +# You should have received a copy of the GNU General Public License |
1770 | +# along with this program. If not, see <http://www.gnu.org/licenses/> |
1771 | +# |
1772 | +############################################################################## |
1773 | + |
1774 | + |
1775 | +from osv import fields,osv |
1776 | +from xml.dom.minidom import Document |
1777 | +from tools.translate import _ |
1778 | +import httplib |
1779 | +import xml2dic |
1780 | +import base64 |
1781 | +import time |
1782 | +import datetime |
1783 | +from urlparse import urlparse |
1784 | +import Image |
1785 | +import tempfile |
1786 | +import re |
1787 | + |
1788 | +pack_type={'01' : 'UPS Letter', |
1789 | +'02' : 'Customer Supplied Package', |
1790 | +'03' : 'Tube', |
1791 | +'04' : 'PAK', |
1792 | +'21' : 'UPS ExpressBox', |
1793 | +'24' : 'UPS 25KG Box', |
1794 | +'25' : 'UPS 10KG Box', |
1795 | +'30' : 'Pallet', |
1796 | +'2a' : 'Small Express Box', |
1797 | +'2b' : 'Medium Express Box', |
1798 | +'2c' : 'Large Express Box'} |
1799 | + |
1800 | + |
1801 | +class email_template(osv.osv): |
1802 | + |
1803 | + _inherit = "email.template" |
1804 | + |
1805 | + _columns = { |
1806 | + 'ship_mail' : fields.boolean('Ship Confirm Mail', help='Check this field to send mail when shipping is done.'), |
1807 | + } |
1808 | + |
1809 | + |
1810 | +email_template() |
1811 | + |
1812 | + |
1813 | + |
1814 | +class shipping_move(osv.osv): |
1815 | + _inherit = "shipping.move" |
1816 | + _columns = { |
1817 | + |
1818 | + 'shipment_identific_no': fields.char('ShipmentIdentificationNumber', size=64, ), |
1819 | + 'logo':fields.binary('Logo'), |
1820 | + 'tracking_url':fields.char('Tracking URL', size=512, ), |
1821 | + 'service': fields.many2one('ups.shipping.service.type', 'Shipping Service'), |
1822 | + |
1823 | + } |
1824 | + def print_label(self, cr, uid, ids, context=None): |
1825 | + if not ids: return [] |
1826 | + |
1827 | +# check_layout = self.browse(cr, uid, ids[0], context=context).company_id.check_layout |
1828 | + |
1829 | + return { |
1830 | + 'type': 'ir.actions.report.xml', |
1831 | + 'report_name':'ship.log.label.print', |
1832 | + 'datas': { |
1833 | + 'model':'shipping.move', |
1834 | + 'id': ids and ids[0] or False, |
1835 | + 'ids': ids and ids or [], |
1836 | + 'report_type': 'pdf' |
1837 | + }, |
1838 | + 'nodestroy': True |
1839 | + } |
1840 | + def getTrackingUrl(self,cr, uid, ids, context=None): |
1841 | + ship_log_obj = self.browse(cr, uid, ids[0], context=context) |
1842 | + if ship_log_obj.tracking_no: |
1843 | + tracking_url = """http://wwwapps.ups.com/WebTracking/processInputRequest?sort_by=status&tracknums_displayed=1&TypeOfInquiryNumber=T&loc=en_US&InquiryNumber1=%s&track.x=0&track.y=0""" % ship_log_obj.tracking_no |
1844 | + |
1845 | + |
1846 | +shipping_move() |
1847 | + |
1848 | + |
1849 | + |
1850 | +class stock_picking(osv.osv): |
1851 | + |
1852 | + _inherit = "stock.picking" |
1853 | + _columns={ |
1854 | + 'ups_service': fields.many2one('ups.shipping.service.type','Service',help='The specific shipping service offered'), |
1855 | + 'shipper': fields.many2one('ups.account.shipping','Shipper',help='The specific user ID and shipper. Setup in the company configuration.'), |
1856 | + 'shipment_digest': fields.text('ShipmentDigest'), |
1857 | + 'negotiated_rates': fields.float('NegotiatedRates'), |
1858 | + 'shipment_identific_no': fields.char('ShipmentIdentificationNumber', size=64, ), |
1859 | + 'tracking_no': fields.char('TrackingNumber', size=64, ), |
1860 | + 'logo':fields.binary('Logo'), |
1861 | + 'trade_mark': fields.related('shipper','trademark',type='char',size=1024,string='Trademark'), |
1862 | + } |
1863 | + |
1864 | + def action_process(self, cr, uid, ids, context=None): |
1865 | + deliv_order = self.browse(cr, uid, type(ids)==type([]) and ids[0] or ids, context=context) |
1866 | + do_transaction = True |
1867 | + if deliv_order.sale_id and deliv_order.sale_id.payment_method == 'cc_pre_auth' and not deliv_order.sale_id.invoiced: |
1868 | + |
1869 | + rel_voucher_id = deliv_order.sale_id.rel_account_voucher_id and deliv_order.sale_id.rel_account_voucher_id.id or False |
1870 | + if rel_voucher_id and deliv_order.sale_id.rel_account_voucher_id.state != 'posted' and deliv_order.sale_id.rel_account_voucher_id.cc_auth_code: |
1871 | + do_transaction = False |
1872 | + self.pool.get('account.voucher').write(cr,uid,[rel_voucher_id],{'cc_p_authorize':False,'cc_charge':True}) |
1873 | + do_transaction = self.pool.get('account.voucher').authorize(cr, uid, [rel_voucher_id], context=context) |
1874 | + if not do_transaction: |
1875 | + self.write(cr,uid,ids,{'ship_state':'hold','ship_message':'Unable to process creditcard payment.'}) |
1876 | + cr.commit() |
1877 | + raise osv.except_osv(_('Final credit card charge cannot be completed!'),_("Please hold shipment and contact customer service..") ) |
1878 | + return super(stock_picking, self).action_process(cr, uid, ids, context=context) |
1879 | + |
1880 | + def action_done(self, cr, uid, ids, context=None): |
1881 | + |
1882 | + res = super(stock_picking, self).action_done(cr, uid, ids, context=context) |
1883 | + if ids: |
1884 | + for stock_pick_obj in self.pool.get('stock.picking').browse(cr,uid,ids): |
1885 | + vals={} |
1886 | + if stock_pick_obj.sale_id: |
1887 | + if stock_pick_obj.sale_id.ship_method: |
1888 | + ups_shipping_service_type_ids=self.pool.get('ups.shipping.service.type').search(cr,uid,[('description','like',stock_pick_obj.sale_id.ship_method)]) |
1889 | + if ups_shipping_service_type_ids: |
1890 | + vals['ups_service']=ups_shipping_service_type_ids[0] |
1891 | + ups_shipping_service_type_obj=self.pool.get('ups.shipping.service.type').browse(cr,uid,ups_shipping_service_type_ids[0]) |
1892 | + if ups_shipping_service_type_obj.ups_account_id: |
1893 | + vals['shipper']=ups_shipping_service_type_obj.ups_account_id.id |
1894 | + if ups_shipping_service_type_obj.ups_account_id.logistic_company_id: |
1895 | + vals['logis_company']=ups_shipping_service_type_obj.ups_account_id.logistic_company_id.id |
1896 | + if vals: |
1897 | + self.write(cr,uid,ids,vals) |
1898 | + return True |
1899 | + def print_labels(self, cr, uid, ids, context=None): |
1900 | + if not ids: return [] |
1901 | +# check_layout = self.browse(cr, uid, ids[0], context=context).company_id.check_layout |
1902 | + return { |
1903 | + 'type': 'ir.actions.report.xml', |
1904 | + 'report_name':'multiple.label.print', |
1905 | + 'datas': { |
1906 | + 'model':'stock.picking', |
1907 | + 'id': ids and ids[0] or False, |
1908 | + 'ids': ids and ids or [], |
1909 | + 'report_type': 'pdf' |
1910 | + }, |
1911 | + 'nodestroy': True |
1912 | + } |
1913 | + |
1914 | + def on_change_sale_id(self, cr, uid, ids, sale_id=False, state=False, context=None): |
1915 | + vals={} |
1916 | + if sale_id: |
1917 | + sale_order_obj=self.pool.get('sale.order').browse(cr,uid,sale_id) |
1918 | + ups_shipping_service_ids=self.pool.get('ups.shipping.service.type').search(cr,uid,[('description','=',sale_order_obj.ship_method)]) |
1919 | + |
1920 | + if type(ups_shipping_service_ids)==type([]) and len(ups_shipping_service_ids)>0: |
1921 | + vals['ups_service']=ups_shipping_service_ids[0] |
1922 | + ups_shipping_account_ids=self.pool.get('ups.account.shipping').search(cr,uid,[('ups_shipping_service_ids','in',ups_shipping_service_ids[0])]) |
1923 | + |
1924 | + if type(ups_shipping_account_ids)==type([]) and len(ups_shipping_account_ids)>0: |
1925 | + vals['shipper']=ups_shipping_account_ids[0] |
1926 | + logistic_company_ids=self.pool.get('logistic.company').search(cr,uid,[('ups_shipping_account_ids','in',ups_shipping_account_ids[0])]) |
1927 | + |
1928 | + if type(logistic_company_ids)==type([]) and len(logistic_company_ids)>0: |
1929 | + vals['logis_company']=logistic_company_ids[0] |
1930 | + |
1931 | + return {'value':vals} |
1932 | + |
1933 | + |
1934 | + def process_void(self,cr, uid, ids, context=None): |
1935 | + error_flag = False |
1936 | + if type(ids)==type([]): |
1937 | + pick_obj=self.pool.get('stock.picking').browse(cr, uid, ids[0]) |
1938 | + else: |
1939 | + pick_obj=self.pool.get('stock.picking').browse(cr, uid, ids) |
1940 | + |
1941 | + |
1942 | +###create the acces req xml first |
1943 | + data_for_Access_Request={ |
1944 | + 'AccessLicenseNumber':pick_obj.shipper.id and pick_obj.shipper.accesslicensenumber or '', |
1945 | + 'UserId':pick_obj.shipper.id and pick_obj.shipper.userid or '', |
1946 | + 'Password':pick_obj.shipper.id and pick_obj.shipper.password or '' |
1947 | + } |
1948 | + response = '' |
1949 | + for pack in pick_obj.packages_ids: |
1950 | + |
1951 | + data_for_void_shipment={'VoidShipmentRequest':{'Request':{ |
1952 | + 'RequestAction':"1", |
1953 | + 'TransactionReference':{'CustomerContext':"",}, |
1954 | + }, |
1955 | + 'ShipmentIdentificationNumber':pack.shipment_identific_no or '', |
1956 | + |
1957 | + 'ExpandedVoidShipment':{ |
1958 | + 'ShipmentIdentificationNumber':pack.shipment_identific_no or '', |
1959 | + 'TrackingNumber':pack.tracking_no or '' |
1960 | + } |
1961 | + } |
1962 | + } |
1963 | + |
1964 | + |
1965 | + doc2=Document() |
1966 | + VoidShipmentRequest = doc2.createElement("VoidShipmentRequest") |
1967 | + doc2.appendChild(VoidShipmentRequest) |
1968 | + |
1969 | + Request = doc2.createElement("Request") |
1970 | + VoidShipmentRequest.appendChild(Request) |
1971 | + |
1972 | + |
1973 | + RequestAction = doc2.createElement("RequestAction") |
1974 | + ptext = doc2.createTextNode(data_for_void_shipment["VoidShipmentRequest"]['Request']['RequestAction']) |
1975 | + RequestAction.appendChild(ptext) |
1976 | + Request.appendChild(RequestAction) |
1977 | + |
1978 | + TransactionReference = doc2.createElement("TransactionReference") |
1979 | + Request.appendChild(TransactionReference) |
1980 | + |
1981 | + CustomerContext = doc2.createElement("CustomerContext") |
1982 | + ptext = doc2.createTextNode(data_for_void_shipment["VoidShipmentRequest"]['Request']['TransactionReference']['CustomerContext']) |
1983 | + CustomerContext.appendChild(ptext) |
1984 | + TransactionReference.appendChild(CustomerContext) |
1985 | + |
1986 | +# ShipmentIdentificationNumber = doc2.createElement("ShipmentIdentificationNumber") |
1987 | +# ptext = doc2.createTextNode(data_for_void_shipment["VoidShipmentRequest"]['ShipmentIdentificationNumber']) |
1988 | +# ShipmentIdentificationNumber.appendChild(ptext) |
1989 | +# VoidShipmentRequest.appendChild(ShipmentIdentificationNumber) |
1990 | + # |
1991 | + |
1992 | + |
1993 | + ExpandedVoidShipment = doc2.createElement("ExpandedVoidShipment") |
1994 | + VoidShipmentRequest.appendChild(ExpandedVoidShipment) |
1995 | + |
1996 | + ShipmentIdentificationNumber = doc2.createElement("ShipmentIdentificationNumber") |
1997 | + ptext = doc2.createTextNode(data_for_void_shipment["VoidShipmentRequest"]['ExpandedVoidShipment']['ShipmentIdentificationNumber']) |
1998 | + ShipmentIdentificationNumber.appendChild(ptext) |
1999 | + ExpandedVoidShipment.appendChild(ShipmentIdentificationNumber) |
2000 | + |
2001 | + TrackingNumber = doc2.createElement("TrackingNumber") |
2002 | + ptext = doc2.createTextNode(data_for_void_shipment["VoidShipmentRequest"]['ExpandedVoidShipment']['TrackingNumber']) |
2003 | + TrackingNumber.appendChild(ptext) |
2004 | + ExpandedVoidShipment.appendChild(TrackingNumber) |
2005 | + |
2006 | + Request_string2=doc2.toprettyxml() |
2007 | + |
2008 | + |
2009 | + |
2010 | + doc1 = Document() |
2011 | + AccessRequest = doc1.createElement("AccessRequest") |
2012 | + AccessRequest.setAttribute("xml:lang", "en-US") |
2013 | + doc1.appendChild(AccessRequest) |
2014 | + |
2015 | + |
2016 | + AccessLicenseNumber = doc1.createElement("AccessLicenseNumber") |
2017 | + ptext = doc1.createTextNode(data_for_Access_Request["AccessLicenseNumber"]) |
2018 | + AccessLicenseNumber.appendChild(ptext) |
2019 | + AccessRequest.appendChild(AccessLicenseNumber) |
2020 | + |
2021 | + UserId = doc1.createElement("UserId") |
2022 | + ptext = doc1.createTextNode(data_for_Access_Request["UserId"]) |
2023 | + UserId.appendChild(ptext) |
2024 | + AccessRequest.appendChild(UserId) |
2025 | + |
2026 | + Password = doc1.createElement("Password") |
2027 | + ptext = doc1.createTextNode(data_for_Access_Request["Password"]) |
2028 | + Password.appendChild(ptext) |
2029 | + AccessRequest.appendChild(Password) |
2030 | + |
2031 | + Request_string1=doc1.toprettyxml() |
2032 | + |
2033 | + Request_string=Request_string1+Request_string2 |
2034 | + |
2035 | + |
2036 | +# Request_string = '''<?xml version="1.0" ?> |
2037 | +#<AccessRequest xml:lang='en-US'> |
2038 | +#<AccessLicenseNumber>3C70E997ECE04388</AccessLicenseNumber> |
2039 | +#<UserId>kdunn.cva</UserId> |
2040 | +#<Password>heckethorn</Password> |
2041 | +#</AccessRequest> |
2042 | +#<?xml version="1.0" encoding="UTF-8" ?> |
2043 | +#<VoidShipmentRequest> |
2044 | +#<Request> |
2045 | +#<TransactionReference> |
2046 | +#<CustomerContext>Customer Transaction ID</CustomerContext> |
2047 | +#<XpciVersion>1.0001</XpciVersion> |
2048 | +#</TransactionReference> |
2049 | +#<RequestAction>Void</RequestAction> |
2050 | +#<RequestOption /> |
2051 | +#</Request> |
2052 | +#<ExpandedVoidShipment> |
2053 | +#<ShipmentIdentificationNumber> |
2054 | +#1Z2220060294314162 |
2055 | +#</ShipmentIdentificationNumber> |
2056 | +#<TrackingNumber>1Z2220060291994175</TrackingNumber> |
2057 | +#</ExpandedVoidShipment> |
2058 | +#</VoidShipmentRequest>''' |
2059 | + if pick_obj.logis_company.test_mode: |
2060 | + void_web = pick_obj.logis_company.ship_void_test_web or '' |
2061 | + void_port = pick_obj.logis_company.ship_void_test_port |
2062 | + else: |
2063 | + void_web = pick_obj.logis_company.ship_void_web or '' |
2064 | + void_port = pick_obj.logis_company.ship_void_port |
2065 | + if void_web: |
2066 | + parse_url = urlparse(void_web) |
2067 | + serv = parse_url.netloc |
2068 | + serv_path = parse_url.path |
2069 | + else: |
2070 | + raise osv.except_osv(_('Unable to find Shipping URL!'),_("Please configure the shipping company with websites.") ) |
2071 | + |
2072 | + |
2073 | + conn=httplib.HTTPSConnection(serv,void_port) |
2074 | + res=conn.request("POST",serv_path,Request_string) |
2075 | + res=conn.getresponse() |
2076 | + result = res.read() |
2077 | + response_dic=xml2dic.main(result) |
2078 | + response = '' |
2079 | + error_flag=False |
2080 | + for elm in response_dic['VoidShipmentResponse'][0]['Response']: |
2081 | + if 'ResponseStatusCode' in elm.keys(): |
2082 | + response += 'ResponseStatusCode:'+str(elm['ResponseStatusCode'])+'\n' |
2083 | + if 'ResponseStatusDescription' in elm.keys(): |
2084 | + response += 'ResponseStatusDescription:'+str(elm['ResponseStatusDescription'])+'\n' |
2085 | + if 'Error' in elm.keys(): |
2086 | + error_flag = True |
2087 | + response += 'Error:'+str(elm['Error'])+'\n' |
2088 | + |
2089 | + |
2090 | + response = 'Void:\n'+response |
2091 | + self.pool.get('stock.packages').write(cr,uid,pack.id,{'ship_message':str(response)}) |
2092 | + |
2093 | + if not error_flag: |
2094 | + self.pool.get('stock.picking').write(cr, uid, ids,{'ship_state':'void','ship_message':''}) |
2095 | + else: |
2096 | + self.pool.get('stock.picking').write(cr, uid, ids,{'ship_message':response}) |
2097 | + return True |
2098 | + |
2099 | + |
2100 | + def get_package(self,pack_obj): |
2101 | + if not pack_obj: |
2102 | + return [] |
2103 | + else: |
2104 | + ret = [] |
2105 | + ret.append({ |
2106 | + 'Description':"",'PackagingType':{'Code':pack_obj.package_type or "",'Description':pack_type.get(pack_obj.package_type , "")},#PackagingType |
2107 | + 'Dimensions':{'UnitOfMeasurement':{'Code':"IN",'Description':"Inches"},'Length':str(pack_obj.length or "0"),'Width':str(pack_obj.width or "0"),'Height':str(pack_obj.height or "0")},#Dimensions |
2108 | + 'PackageWeight':{'UnitOfMeasurement':{'Code':"LBS",'Description':"Pounds"},'Weight':str(pack_obj.weight or "0")}, |
2109 | +# 'LargePackageIndicator':"", |
2110 | + 'ReferenceNumber':{'BarCodeIndicator':"",'Code':pack_obj.ref1 or "",'Value':""}, |
2111 | +# 'AdditionalHandling':"", |
2112 | +# 'PackageServiceOptions':{'DeliveryConfirmation':{'DCISType':"",'DCISNumber':""},#DeliveryConfirmation |
2113 | +# 'InsuredValue':{'Type':"",'Code':"",'Description':"", |
2114 | +# 'CurrencyCode':"",'MonetaryValue':"" |
2115 | +# },#InsuredValue |
2116 | +# 'COD':{'CODCode':"",'CODFundsCode':"", |
2117 | +# 'CODAmount':{'CurrencyCode':"", |
2118 | +# 'MonetaryValue':"" |
2119 | +# },#CODAmount |
2120 | +# },#COD |
2121 | +# 'VerbalConfirmation':{ContactInfo:{'Name':"",'PhoneNumber':""}#ContactInfo |
2122 | +# },#VerbalConfirmation |
2123 | +# 'ShipperReleaseIndicator':"", |
2124 | +# 'Notification':{'NotificationCode':"", |
2125 | +# 'EMailMessage':{'EMailAddress':"",'UndeliverableEMailAddress':"", |
2126 | +# 'FromEMailAddress':"",'FromName':"",'Memo':"", |
2127 | +# 'Subject':"",'SubjectCode':""}#EMailMessage |
2128 | +# },#Notification, |
2129 | +# 'ReturnsFlexibleAccessIndicator':"", |
2130 | +# }#PackageServiceOptions |
2131 | + }) |
2132 | + return ret |
2133 | + |
2134 | + def fill_addr(self,addr_id): |
2135 | + ret = {'AddressLine1':addr_id and addr_id.street or '', |
2136 | + 'AddressLine2':addr_id and addr_id.street2 or '', |
2137 | + 'AddressLine3':"", |
2138 | + 'City':addr_id and addr_id.city or '', |
2139 | + 'StateProvinceCode':addr_id and addr_id.state_id.id and addr_id.state_id.code or '', |
2140 | + 'PostalCode':addr_id and addr_id.zip or '', |
2141 | + 'CountryCode':addr_id and addr_id.country_id.id and addr_id.country_id.code or '', |
2142 | + 'ResidentialAddress':"", |
2143 | + } |
2144 | + |
2145 | + if addr_id and ('zip_id' in addr_id._columns.keys()): |
2146 | + ret['PostalCode'] = addr_id.zip_id.id and str(addr_id.zip_id.zipcode) or '' |
2147 | + return ret |
2148 | + |
2149 | + def create_ship_accept_request(self,cr, uid, ids,package_id): |
2150 | + package_obj=self.pool.get('stock.packages').browse(cr, uid, package_id) |
2151 | + |
2152 | +###create the acces req xml first |
2153 | + data_for_Access_Request={ |
2154 | + 'AccessLicenseNumber':package_obj.pick_id.shipper.id and package_obj.pick_id.shipper.accesslicensenumber or '', |
2155 | + 'UserId':package_obj.pick_id.shipper.id and package_obj.pick_id.shipper.userid or '', |
2156 | + 'Password':package_obj.pick_id.shipper.id and package_obj.pick_id.shipper.password or '' |
2157 | + } |
2158 | + |
2159 | + doc1 = Document() |
2160 | + AccessRequest = doc1.createElement("AccessRequest") |
2161 | + AccessRequest.setAttribute("xml:lang", "en-US") |
2162 | + doc1.appendChild(AccessRequest) |
2163 | + |
2164 | + |
2165 | + AccessLicenseNumber = doc1.createElement("AccessLicenseNumber") |
2166 | + ptext = doc1.createTextNode(data_for_Access_Request["AccessLicenseNumber"]) |
2167 | + AccessLicenseNumber.appendChild(ptext) |
2168 | + AccessRequest.appendChild(AccessLicenseNumber) |
2169 | + |
2170 | + UserId = doc1.createElement("UserId") |
2171 | + ptext = doc1.createTextNode(data_for_Access_Request["UserId"]) |
2172 | + UserId.appendChild(ptext) |
2173 | + AccessRequest.appendChild(UserId) |
2174 | + |
2175 | + Password = doc1.createElement("Password") |
2176 | + ptext = doc1.createTextNode(data_for_Access_Request["Password"]) |
2177 | + Password.appendChild(ptext) |
2178 | + AccessRequest.appendChild(Password) |
2179 | + |
2180 | + Request_string1=doc1.toprettyxml() |
2181 | + |
2182 | + |
2183 | + |
2184 | + data_for_Ship_Accept = {'ShipmentAcceptRequest':{ |
2185 | + 'Request':{ |
2186 | + 'RequestAction':'ShipAccept', |
2187 | + 'TransactionReference':{'CustomerContext':''} |
2188 | + }, |
2189 | + 'ShipmentDigest':package_obj.shipment_digest |
2190 | + } |
2191 | + } |
2192 | + |
2193 | + |
2194 | + doc2 = Document() |
2195 | + ShipmentAcceptRequest = doc2.createElement("ShipmentAcceptRequest") |
2196 | + ShipmentAcceptRequest.setAttribute("xml:lang", "en-US") |
2197 | + doc2.appendChild(ShipmentAcceptRequest) |
2198 | + |
2199 | + |
2200 | + |
2201 | + Request = doc2.createElement("Request") |
2202 | + ShipmentAcceptRequest.appendChild(Request) |
2203 | + |
2204 | + |
2205 | + RequestAction = doc2.createElement("RequestAction") |
2206 | + ptext = doc1.createTextNode(data_for_Ship_Accept['ShipmentAcceptRequest']["Request"]['RequestAction']) |
2207 | + RequestAction.appendChild(ptext) |
2208 | + Request.appendChild(RequestAction) |
2209 | + |
2210 | + |
2211 | + TransactionReference = doc2.createElement("TransactionReference") |
2212 | + Request.appendChild(TransactionReference) |
2213 | + |
2214 | + CustomerContext = doc2.createElement("CustomerContext") |
2215 | + ptext = doc1.createTextNode(data_for_Ship_Accept['ShipmentAcceptRequest']["Request"]['TransactionReference']['CustomerContext']) |
2216 | + CustomerContext.appendChild(ptext) |
2217 | + TransactionReference.appendChild(CustomerContext) |
2218 | + |
2219 | + ShipmentDigest = doc2.createElement("ShipmentDigest") |
2220 | + ptext = doc1.createTextNode(data_for_Ship_Accept['ShipmentAcceptRequest']["ShipmentDigest"]) |
2221 | + ShipmentDigest.appendChild(ptext) |
2222 | + ShipmentAcceptRequest.appendChild(ShipmentDigest) |
2223 | + |
2224 | + Request_string2=doc2.toprettyxml() |
2225 | + request_string=Request_string1+Request_string2 |
2226 | + |
2227 | + return request_string |
2228 | + |
2229 | + def process_ship_accept(self,cr, uid, ids,ship_move_ids,pack_obj,context=None): |
2230 | + |
2231 | + |
2232 | + shipment_accept_request_xml=self.create_ship_accept_request(cr, uid, ids,pack_obj.id) |
2233 | + |
2234 | + if pack_obj.pick_id.logis_company.test_mode: |
2235 | + acce_web = pack_obj.pick_id.logis_company.ship_accpt_test_web or '' |
2236 | + acce_port = pack_obj.pick_id.logis_company.ship_accpt_test_port |
2237 | + else: |
2238 | + acce_web = pack_obj.pick_id.logis_company.ship_accpt_web or '' |
2239 | + acce_port = pack_obj.pick_id.logis_company.ship_accpt_port |
2240 | + if acce_web: |
2241 | + parse_url = urlparse(acce_web) |
2242 | + serv = parse_url.netloc |
2243 | + serv_path = parse_url.path |
2244 | + else: |
2245 | + raise osv.except_osv(_('Unable to find Shipping URL!'),_("Please configure the shipping company with websites.") ) |
2246 | + |
2247 | + |
2248 | + |
2249 | + conn=httplib.HTTPSConnection(serv,acce_port) |
2250 | + res=conn.request("POST",serv_path,shipment_accept_request_xml) |
2251 | + res=conn.getresponse() |
2252 | + result = res.read() |
2253 | + response_dic=xml2dic.main(result) |
2254 | + NegotiatedRates='' |
2255 | + ShipmentIdentificationNumber='' |
2256 | + TrackingNumber='' |
2257 | + label_image='' |
2258 | + if response_dic['ShipmentAcceptResponse'][0]['Response'][0]['ResponseStatusCode'] == '1': |
2259 | + if len(response_dic['ShipmentAcceptResponse'])>1 and response_dic['ShipmentAcceptResponse'][1].has_key('ShipmentResults'): |
2260 | + if len(response_dic['ShipmentAcceptResponse'][1]['ShipmentResults'])>1 and response_dic['ShipmentAcceptResponse'][1]['ShipmentResults'][1].has_key('NegotiatedRates'): |
2261 | + if len(response_dic['ShipmentAcceptResponse'][1]['ShipmentResults'][1]['NegotiatedRates'])>0 and response_dic['ShipmentAcceptResponse'][1]['ShipmentResults'][1]['NegotiatedRates'][0].has_key('NetSummaryCharges'): |
2262 | + if len(response_dic['ShipmentAcceptResponse'][1]['ShipmentResults'][1]['NegotiatedRates'][0]['NetSummaryCharges'])>0 and response_dic['ShipmentAcceptResponse'][1]['ShipmentResults'][1]['NegotiatedRates'][0]['NetSummaryCharges'][0].has_key('GrandTotal'): |
2263 | + NegotiatedRates=response_dic['ShipmentAcceptResponse'][1]['ShipmentResults'][1]['NegotiatedRates'][0]['NetSummaryCharges'][0]['GrandTotal'][1]['MonetaryValue'] |
2264 | + |
2265 | + if len(response_dic['ShipmentAcceptResponse'][1]['ShipmentResults'])>0 and response_dic['ShipmentAcceptResponse'][1]['ShipmentResults'][3].has_key('ShipmentIdentificationNumber'): |
2266 | + ShipmentIdentificationNumber=response_dic['ShipmentAcceptResponse'][1]['ShipmentResults'][3]['ShipmentIdentificationNumber'] |
2267 | + |
2268 | + if len(response_dic['ShipmentAcceptResponse'][1]['ShipmentResults'])>4 and response_dic['ShipmentAcceptResponse'][1]['ShipmentResults'][4].has_key('PackageResults') : |
2269 | + if len(response_dic['ShipmentAcceptResponse'][1]['ShipmentResults'][4]['PackageResults'])>0: |
2270 | + TrackingNumber=response_dic['ShipmentAcceptResponse'][1]['ShipmentResults'][4]['PackageResults'][0]['TrackingNumber'] |
2271 | + |
2272 | + if len(response_dic['ShipmentAcceptResponse'][1]['ShipmentResults'][4]['PackageResults'])>2 and response_dic['ShipmentAcceptResponse'][1]['ShipmentResults'][4]['PackageResults'][2].has_key('LabelImage') : |
2273 | + label_image =response_dic['ShipmentAcceptResponse'][1]['ShipmentResults'][4]['PackageResults'][2]['LabelImage'][1]['GraphicImage'] |
2274 | + if TrackingNumber: |
2275 | + tracking_url = pack_obj.pick_id.logis_company.ship_tracking_url |
2276 | + if tracking_url: |
2277 | + try: |
2278 | + tracking_url = tracking_url%TrackingNumber |
2279 | + except Exception, e: |
2280 | + tracking_url = "Invalid tracking url on shipping company" |
2281 | +# tracking_url = """http://wwwapps.ups.com/WebTracking/processInputRequest?sort_by=status&tracknums_displayed=1&TypeOfInquiryNumber=T&loc=en_US&InquiryNumber1=%s&track.x=0&track.y=0""" % TrackingNumber |
2282 | + else: |
2283 | + tracking_url = '' |
2284 | + if label_image: |
2285 | + im_in_raw=base64.decodestring(label_image) |
2286 | + path=tempfile.mktemp() |
2287 | + temp=file(path,'wb') |
2288 | + temp.write(im_in_raw) |
2289 | + temp.close() |
2290 | + new_im=Image.open(path) |
2291 | + new_im=new_im.rotate(270) |
2292 | + new_im.save(path,'JPEG') |
2293 | + label_from_file=open(path,'rb') |
2294 | + label_image=base64.encodestring(label_from_file.read()) |
2295 | + label_from_file.close() |
2296 | + |
2297 | + self.pool.get('stock.packages').write(cr,uid,[pack_obj.id],{'tracking_no':TrackingNumber or "", |
2298 | + 'shipment_identific_no':ShipmentIdentificationNumber or "", |
2299 | + 'negotiated_rates':NegotiatedRates or '', |
2300 | + 'logo':label_image, |
2301 | + 'ship_state':'in_process', |
2302 | + 'tracking_url':tracking_url}) |
2303 | + |
2304 | + if ship_move_ids.get(pack_obj.id): |
2305 | + if TrackingNumber: |
2306 | + tracking_url = pack_obj.pick_id.logis_company.ship_tracking_url |
2307 | + if tracking_url: |
2308 | + try: |
2309 | + tracking_url = tracking_url%TrackingNumber |
2310 | + except Exception, e: |
2311 | + tracking_url = "Invalid tracking url on shipping company" |
2312 | + else: |
2313 | + tracking_url = '' |
2314 | + self.pool.get('shipping.move').write(cr, uid, [ship_move_ids.get(pack_obj.id)], {'tracking_no':TrackingNumber or "", |
2315 | + 'shipment_identific_no':ShipmentIdentificationNumber or "", |
2316 | + 'ship_cost':NegotiatedRates or '', |
2317 | + 'logo':label_image, |
2318 | + 'state':'ready_pick', |
2319 | + 'tracking_url':tracking_url}) |
2320 | +# t_string="Package id : "+str(pack_obj.id) |
2321 | +# t_string+="\n"+(pack_obj.pick_id.ship_message or '') |
2322 | +# self.pool.get('stock.picking').write(cr, uid,[pack_obj.pick_id.id], {'ship_message': t_string}) |
2323 | + |
2324 | + return True |
2325 | + def add_product(self, cr, uid, package_obj): |
2326 | + prods = [] |
2327 | + tot_weight = 0 |
2328 | + for pkg in package_obj.pick_id.packages_ids: |
2329 | + tot_weight += pkg.weight |
2330 | + for move_lines in package_obj.pick_id.move_lines: |
2331 | + product_id = move_lines.product_id |
2332 | + if move_lines.product_id.supply_method == 'produce': |
2333 | + produce = "Yes" |
2334 | + else: |
2335 | + produce = "NO[1]" |
2336 | + product={'Description':move_lines.product_id.description or " ", |
2337 | + 'Unit':{'Number':str(int(move_lines.product_qty) or 0), |
2338 | + 'Value':str((move_lines.product_id.list_price * move_lines.product_qty) or 0), |
2339 | + 'UnitOfMeasurement':{'Code':"LBS",'Description':"Pounds"} |
2340 | + }, |
2341 | + 'CommodityCode':package_obj.pick_id.comm_code or "", |
2342 | + 'PartNumber':"", |
2343 | + 'OriginCountryCode':package_obj.pick_id.address_id and package_obj.pick_id.address_id.country_id and package_obj.pick_id.address_id.country_id.code or "", |
2344 | + 'JointProductionIndicator':"", |
2345 | + 'NetCostCode':"NO", |
2346 | +# 'NetCostDateRange':{'BeginDate':"",'EndDate':""}, Not required |
2347 | + 'PreferenceCriteria':"B", |
2348 | + 'ProducerInfo':produce, |
2349 | + 'MarksAndNumbers':"", |
2350 | + 'NumberOfPackagesPerCommodity':str(len(package_obj.pick_id.packages_ids)), |
2351 | + 'ProductWeight':{'UnitOfMeasurement':{'Code':"LBS",'Description':"Pounds"}, |
2352 | + 'Weight':"%.1f"%(tot_weight or '0')}, |
2353 | + 'VehicleID':"", |
2354 | +# THis is only needed for sed |
2355 | +# 'ScheduleB':{'Number':"", |
2356 | +# 'Quantity':"", |
2357 | +# 'UnitOfMeasurement':{'Code':"",'Description':""}, |
2358 | +# 'ExportType':"", |
2359 | +# 'SEDTotalValue':"" |
2360 | +# }, |
2361 | + } |
2362 | + prods.append(product) |
2363 | + return prods |
2364 | + def create_comm_inv(self, cr, uid, package_obj): |
2365 | + invoice_id = False |
2366 | + if package_obj.pick_id.sale_id: |
2367 | + if package_obj.pick_id.sale_id.invoice_ids: |
2368 | + invoice_id = package_obj.pick_id.sale_id.invoice_ids[0] |
2369 | + user = self.pool.get('res.users').browse(cr, uid, uid) |
2370 | + comm_inv={ 'FormType':"01", |
2371 | +# 'AdditionalDocumentIndicator':"", Not required |
2372 | +# 'FormGroupIdName':"", Not required |
2373 | + 'Product':[],#Placed out of this dictionary for common use |
2374 | + 'InvoiceNumber':"", |
2375 | + 'InvoiceDate':"", |
2376 | + 'PurchaseOrderNumber':"", |
2377 | + 'TermsOfShipment':"", |
2378 | + 'ReasonForExport':"SALE", |
2379 | + 'Comments':"", |
2380 | + 'DeclarationStatement':"I hereby certify that the good covered by this shipment qualifies as an originating good for purposes of preferential tariff treatment under the NAFTA.", |
2381 | +# 'Discount':{'MonetaryValue':"0"},#Discount Not Required |
2382 | +# 'FreightCharges':{'MonetaryValue':""},#FreightCharges Not Required |
2383 | +# 'InsuranceCharges':{'MonetaryValue':""},#InsuranceCharges Not Required |
2384 | +# 'OtherCharges':{'MonetaryValue':"",'Description':""},#OtherCharges Not Required |
2385 | + 'CurrencyCode':user.company_id.currency_id.name or "", |
2386 | +# 'InBondCode':"", Not Required |
2387 | +# 'EntryNumber':"", Not Required |
2388 | +# 'PointOfOrigin':"", Not Required |
2389 | + } |
2390 | + if invoice_id: |
2391 | + comm_inv['InvoiceNumber'] = invoice_id.number or '/' |
2392 | + if invoice_id.date_invoice: |
2393 | + d=invoice_id.date_invoice |
2394 | + comm_inv['InvoiceDate'] = d[:4]+d[5:7]+d[8:10] |
2395 | + if not comm_inv['InvoiceDate']: |
2396 | + comm_inv['InvoiceDate'] = time.strftime("%Y%m%d") |
2397 | + |
2398 | + return comm_inv |
2399 | + def create_cer_orig(self, cr, uid, package_obj): |
2400 | + cer_orig={ |
2401 | + 'FormType':"03", |
2402 | +# 'AdditionalDocumentIndicator':"", Not Required |
2403 | +# 'FormGroupIdName':"", Not Required |
2404 | + 'Product':[],#Placed out of this dictionary for common use |
2405 | + 'ExportDate':time.strftime("%Y%m%d"), |
2406 | + 'ExportingCarrier':package_obj.pick_id.exp_carrier or "", |
2407 | + } |
2408 | + return cer_orig |
2409 | + def create_nafta_cer_orig(self, cr, uid, package_obj): |
2410 | + addr = {} |
2411 | + if package_obj.pick_id.prod_address_id: |
2412 | + addr_id = package_obj.pick_id.prod_address_id |
2413 | + |
2414 | + addr = {'AddressLine1':addr_id.street or "", |
2415 | + 'AddressLine2':addr_id.street2 or "", |
2416 | + 'City':addr_id.city or "", |
2417 | + 'StateProvinceCode':addr_id.state_id and addr_id.state_id.code or "", |
2418 | + 'PostalCode':addr_id.zip or "", |
2419 | + 'CountryCode':addr_id.country_id and addr_id.country_id.code or "", |
2420 | + } |
2421 | + beg_date=" " |
2422 | + end_date=" " |
2423 | + if package_obj.pick_id.blanket_begin_date: |
2424 | + beg_date = package_obj.pick_id.blanket_begin_date |
2425 | + beg_date = beg_date[:4]+beg_date[5:7]+beg_date[8:10] |
2426 | + if package_obj.pick_id.blanket_end_date: |
2427 | + end_date = package_obj.pick_id.blanket_end_date |
2428 | + end_date = end_date[:4]+end_date[5:7]+end_date[8:10] |
2429 | + nafta_cer_orig={ 'FormType':"04", |
2430 | +# 'AdditionalDocumentIndicator':"", Not Required |
2431 | +# 'FormGroupIdName':"", Not Required |
2432 | + 'Contacts':{ |
2433 | + |
2434 | + 'Producer':{'Option':package_obj.pick_id.prod_option or "", |
2435 | + 'CompanyName':package_obj.pick_id.prod_company or "", |
2436 | + 'TaxIdentificationNumber':package_obj.pick_id.prod_tax_id_no or "", |
2437 | + 'Address':addr,#Address |
2438 | + },#Producer |
2439 | + },#Contacts |
2440 | + 'BlanketPeriod':{ |
2441 | + 'BeginDate':beg_date, |
2442 | + 'EndDate':end_date, |
2443 | + |
2444 | + }, |
2445 | + 'Product':[],#Placed out of this dictionary for common use |
2446 | + } |
2447 | + return nafta_cer_orig |
2448 | +# def create_sed(self, package_obj): |
2449 | +# sed ={ 'FormType':"02", |
2450 | +# 'AdditionalDocumentIndicator':"", |
2451 | +# 'FormGroupIdName':"", |
2452 | +# 'SEDFilingOption':"01", |
2453 | +# 'Contacts':{ |
2454 | +# 'ForwardAgent':{'CompanyName':"", |
2455 | +# 'TaxIdentificationNumber':"", |
2456 | +# 'Address':{'AddressLine1':"", |
2457 | +# 'AddressLine2':"", |
2458 | +# 'City':"", |
2459 | +# 'StateProvinceCode':"", |
2460 | +# 'PostalCode':"", |
2461 | +# 'CountryCode':"", |
2462 | +# },#Address |
2463 | +# |
2464 | +# },#ForwardAgent |
2465 | +# 'UltimateConsignee':{'CompanyName':"", |
2466 | +# 'Address':{'AddressLine1':"", |
2467 | +# 'AddressLine2':"", |
2468 | +# 'City':"", |
2469 | +# 'StateProvinceCode':"", |
2470 | +# 'PostalCode':"", |
2471 | +# 'CountryCode':"", |
2472 | +# },#Address |
2473 | +# },#UltimateConsignee |
2474 | +# |
2475 | +# 'IntermediateConsignee':{'CompanyName':"", |
2476 | +# 'Address':{'AddressLine1':"", |
2477 | +# 'AddressLine2':"", |
2478 | +# 'City':"", |
2479 | +# 'StateProvinceCode':"", |
2480 | +# 'PostalCode':"", |
2481 | +# 'CountryCode':"", |
2482 | +# },#Address |
2483 | +# },#IntermediateConsignee |
2484 | +# |
2485 | +# 'Producer':{'Option':"", |
2486 | +# 'CompanyName':"", |
2487 | +# 'TaxIdentificationNumber':"", |
2488 | +# 'Address':{'AddressLine1':"", |
2489 | +# 'AddressLine2':"", |
2490 | +# 'City':"", |
2491 | +# 'StateProvinceCode':"", |
2492 | +# 'PostalCode':"", |
2493 | +# 'CountryCode':"", |
2494 | +# },#Address |
2495 | +# },#Producer |
2496 | +# },#Contacts |
2497 | +# 'Product':[],#Placed out of this dictionary for common use |
2498 | +# 'ExportDate':"", |
2499 | +# 'ExportingCarrier':"", |
2500 | +# 'CarrierID':"", |
2501 | +# 'InBondCode':"", |
2502 | +# 'EntryNumber':"", |
2503 | +# 'PointOfOrigin':"", |
2504 | +# 'ModeOfTransport':"", |
2505 | +# 'PortOfExport':"", |
2506 | +# 'PortOfUnloading':"", |
2507 | +# 'LoadingPier':"", |
2508 | +# 'PartiesToTransaction':"", |
2509 | +# 'RoutedExportTransactionIndicator':False,#Make it true to add this |
2510 | +# 'ContainerizedIndicator':False,#Make it true to add this |
2511 | +# 'License':{ 'Number':"", |
2512 | +# 'Date':"", |
2513 | +# 'ExceptionCode':"",}, |
2514 | +# 'ECCNNumber':"", |
2515 | +# } |
2516 | +# return sed |
2517 | + |
2518 | + def create_forms(self, cr, uid, package_obj): |
2519 | + comm_inv = {} |
2520 | + cer_orig = {} |
2521 | + nafta_cer_orig = {} |
2522 | + sed = {} |
2523 | + if package_obj.pick_id.comm_inv: |
2524 | + comm_inv = self.create_comm_inv(cr, uid, package_obj) |
2525 | + if package_obj.pick_id.cer_orig: |
2526 | + cer_orig = self.create_cer_orig(cr, uid, package_obj) |
2527 | + if package_obj.pick_id.nafta_cer_orig: |
2528 | + nafta_cer_orig = self.create_nafta_cer_orig(cr, uid, package_obj) |
2529 | +# if package_obj.pick_id.sed: |
2530 | +# sed = self.create_sed(package_obj) |
2531 | + prod = self.add_product(cr, uid, package_obj) |
2532 | +# asd |
2533 | + ret = {'comm_inv':comm_inv,'cer_orig':cer_orig,'nafta_cer_orig':nafta_cer_orig,'sed':sed,'prod':prod} |
2534 | + return ret |
2535 | + def create_ship_confirm_request(self,cr, uid,package_id): |
2536 | + package_obj=self.pool.get('stock.packages').browse(cr, uid, package_id) |
2537 | + |
2538 | +###create the acces req xml first |
2539 | + data_for_Access_Request={ |
2540 | + 'AccessLicenseNumber':package_obj.pick_id.shipper.id and package_obj.pick_id.shipper.accesslicensenumber or '', |
2541 | + 'UserId':package_obj.pick_id.shipper.id and package_obj.pick_id.shipper.userid or '', |
2542 | + 'Password':package_obj.pick_id.shipper.id and package_obj.pick_id.shipper.password or '' |
2543 | + } |
2544 | + |
2545 | + doc1 = Document() |
2546 | + AccessRequest = doc1.createElement("AccessRequest") |
2547 | + AccessRequest.setAttribute("xml:lang", "en-US") |
2548 | + doc1.appendChild(AccessRequest) |
2549 | + |
2550 | + |
2551 | + AccessLicenseNumber = doc1.createElement("AccessLicenseNumber") |
2552 | + ptext = doc1.createTextNode(data_for_Access_Request["AccessLicenseNumber"]) |
2553 | + AccessLicenseNumber.appendChild(ptext) |
2554 | + AccessRequest.appendChild(AccessLicenseNumber) |
2555 | + |
2556 | + UserId = doc1.createElement("UserId") |
2557 | + ptext = doc1.createTextNode(data_for_Access_Request["UserId"]) |
2558 | + UserId.appendChild(ptext) |
2559 | + AccessRequest.appendChild(UserId) |
2560 | + |
2561 | + Password = doc1.createElement("Password") |
2562 | + ptext = doc1.createTextNode(data_for_Access_Request["Password"]) |
2563 | + Password.appendChild(ptext) |
2564 | + AccessRequest.appendChild(Password) |
2565 | + |
2566 | + Request_string1=doc1.toprettyxml() |
2567 | + |
2568 | + |
2569 | +###create the shipment acces req xml |
2570 | + data_for_confirm_request={'ShipmentConfirmRequest':{ |
2571 | + |
2572 | + 'Request':{'RequestAction':"ShipConfirm",#-----must be ShipConfirm |
2573 | + 'RequestOption':package_obj.pick_id.address_validate or "nonvalidate",#----------adress validation |
2574 | + 'TransactionReference':{'CustomerContext':"",},#---------optional data |
2575 | + },#Request |
2576 | + |
2577 | + 'Shipment':{'Description':package_obj.description or "Shipping", |
2578 | + 'ReturnService':{'Code':"8", 'DocumentsOnly':"" }, |
2579 | + 'Shipper':{ 'Name':package_obj.pick_id.shipper.id and package_obj.pick_id.shipper.name or "", |
2580 | + 'AttentionName':package_obj.pick_id.shipper.id and package_obj.pick_id.shipper.atten_name or "", |
2581 | + 'ShipperNumber':package_obj.pick_id.shipper.id and package_obj.pick_id.shipper.acc_no or "", |
2582 | + 'TaxIdentificationNumber':package_obj.pick_id.shipper.id and package_obj.pick_id.shipper.tax_id_no or "", |
2583 | + 'PhoneNumber':package_obj.pick_id.shipper.id and package_obj.pick_id.shipper.address and package_obj.pick_id.shipper.address.phone or "", |
2584 | + 'FaxNumber':package_obj.pick_id.shipper.id and package_obj.pick_id.shipper.address and package_obj.pick_id.shipper.address.fax or "", |
2585 | + 'EMailAddress':package_obj.pick_id.shipper.id and package_obj.pick_id.shipper.address and package_obj.pick_id.shipper.address.email or "", |
2586 | + 'Address':self.fill_addr(package_obj.pick_id.shipper.id and package_obj.pick_id.shipper.address or '') |
2587 | + },#Shipper |
2588 | + |
2589 | + 'ShipTo': {'CompanyName':package_obj.pick_id.address_id.partner_id and package_obj.pick_id.address_id.partner_id.name or '', |
2590 | + 'AttentionName':package_obj.pick_id.inv_att_name or "", |
2591 | + 'TaxIdentificationNumber':"", |
2592 | + 'PhoneNumber':package_obj.pick_id.address_id.id and package_obj.pick_id.address_id.phone or '', |
2593 | + 'FaxNumber':package_obj.pick_id.address_id.id and package_obj.pick_id.address_id.fax or '', |
2594 | + 'EMailAddress':package_obj.pick_id.address_id.id and package_obj.pick_id.address_id.email or '', |
2595 | + 'Address':self.fill_addr(package_obj.pick_id.address_id.id and package_obj.pick_id.address_id), |
2596 | + 'LocationID':"", |
2597 | + },#ShipTo |
2598 | + |
2599 | + |
2600 | + |
2601 | + 'ShipFrom':{'CompanyName':package_obj.pick_id.shipper.id and package_obj.pick_id.shipper.name or "", |
2602 | + 'AttentionName':package_obj.pick_id.shipper.id and package_obj.pick_id.shipper.atten_name or "", |
2603 | + 'TaxIdentificationNumber':package_obj.pick_id.ship_from_tax_id_no or '', |
2604 | + 'PhoneNumber':package_obj.pick_id.address_id.id and package_obj.pick_id.ship_from_address.phone or '', |
2605 | + 'FaxNumber':package_obj.pick_id.address_id.id and package_obj.pick_id.ship_from_address.fax or '', |
2606 | + 'Address':self.fill_addr(package_obj.pick_id.ship_from_address.id and package_obj.pick_id.ship_from_address), |
2607 | + }, |
2608 | + |
2609 | + 'SoldTo':{'Option':package_obj.pick_id.inv_option or " ", |
2610 | + 'CompanyName':package_obj.pick_id.inv_company or "", |
2611 | + 'AttentionName':package_obj.pick_id.inv_att_name or "", |
2612 | + 'TaxIdentificationNumber':package_obj.pick_id.inv_tax_id_no or "", |
2613 | + 'PhoneNumber':package_obj.pick_id.inv_address_id and package_obj.pick_id.inv_address_id.phone or "", |
2614 | + 'Address':{'AddressLine1':package_obj.pick_id.inv_address_id and package_obj.pick_id.inv_address_id.street or "", |
2615 | + 'AddressLine2':package_obj.pick_id.inv_address_id and package_obj.pick_id.inv_address_id.street2 or "", |
2616 | + 'City':package_obj.pick_id.inv_address_id and package_obj.pick_id.inv_address_id.city or "", |
2617 | + 'StateProvinceCode':package_obj.pick_id.inv_address_id and package_obj.pick_id.inv_address_id.state_id and package_obj.pick_id.inv_address_id.state_id.code or "", |
2618 | + 'PostalCode':package_obj.pick_id.inv_address_id and package_obj.pick_id.inv_address_id.zip or "", |
2619 | + 'CountryCode':package_obj.pick_id.inv_address_id and package_obj.pick_id.inv_address_id.country_id and package_obj.pick_id.inv_address_id.country_id.code or "",} |
2620 | + },#SoldTo, |
2621 | + |
2622 | + 'PaymentInformation':{'Prepaid':{ |
2623 | + 'BillShipper':{'AccountNumber':package_obj.pick_id.shipper and package_obj.pick_id.shipper.acc_no or "", |
2624 | +# 'CreditCard':{'Type':"", |
2625 | +# 'Number':"", |
2626 | +# 'ExpirationDate':"", |
2627 | +# 'SecurityCode':"", |
2628 | +# 'Address':{'AddressLine1':"", |
2629 | +# 'AddressLine2':"", |
2630 | +# 'AddressLine3':"", |
2631 | +# 'City':"", |
2632 | +# 'StateProvinceCode':"", |
2633 | +# 'PostalCode':"", |
2634 | +# 'CountryCode':"",}, |
2635 | +# },#CreditCard |
2636 | + },#BillShipper |
2637 | + },#Prepaid |
2638 | +# 'BillThirdParty':{'BillThirdPartyShipper':{'AccountNumber':"", |
2639 | +# 'ThirdParty':{ |
2640 | +# 'Address':{'PostalCode':"", |
2641 | +# 'CountryCode':"",},#Address |
2642 | +# },#ThirdParty |
2643 | +# },#BillThirdPartyShipper |
2644 | +# |
2645 | +# },#BillThirdParty |
2646 | +# |
2647 | +# 'FreightCollect':{'BillReceiver':{'AccountNumber':"", |
2648 | +# 'Address':{'PostalCode':"",},#Address |
2649 | +# },#BillReceiver |
2650 | +# },#FreightCollect |
2651 | +# |
2652 | +# 'ConsigneeBilled':"", |
2653 | + },#PaymentInformation, |
2654 | + |
2655 | +# 'ItemizedPaymentInformation':{ 'ShipmentCharge':{'Type':"", |
2656 | +# 'BillShipper':{'AccountNumber':"", |
2657 | +# 'CreditCard':{'Type':"", |
2658 | +# 'Number':"", |
2659 | +# 'ExpirationDate':"", |
2660 | +# 'SecurityCode':"", |
2661 | +# 'Address':{'AddressLine1':"", |
2662 | +# 'AddressLine2':"", |
2663 | +# 'AddressLine3':"", |
2664 | +# 'City':"", |
2665 | +# 'StateProvinceCode':"", |
2666 | +# 'PostalCode':"", |
2667 | +# 'CountryCode':"",}, |
2668 | +# },#CreditCard |
2669 | +# },#BillShipper |
2670 | +# 'BillReceiver':{'AccountNumber':"",'Address':{'PostalCode':"",},#Address |
2671 | +# },#BillReceiver |
2672 | +# 'BillThirdParty':{'BillThirdPartyShipper':{'AccountNumber':"", |
2673 | +# 'ThirdParty':{ |
2674 | +# 'Address':{'PostalCode':"",'CountryCode':"",},#Address |
2675 | +# },#ThirdParty |
2676 | +# },#BillThirdPartyShipper |
2677 | +# |
2678 | +# 'BillThirdPartyConsignee':{'AccountNumber':"",'ThirdParty':{'Address':{'PostalCode':"", |
2679 | +# 'CountryCode':"",}, #Address |
2680 | +# },#ThirdParty |
2681 | +# },#BillThirdPartyConsignee |
2682 | +# },#BillThirdParty |
2683 | +# 'ConsigneeBilled':"", |
2684 | +# },#ShipmentCharge |
2685 | +# 'SplitDutyVATIndicator':"", |
2686 | +# },#ItemizedPaymentInformation |
2687 | + |
2688 | + 'GoodsNotInFreeCirculationIndicator':"", |
2689 | + 'RateInformation':{'NegotiatedRatesIndicator':""},#RateInformation |
2690 | +# 'MovementReferenceNumber':"", |
2691 | +# 'ReferenceNumber':{'BarCodeIndicator':"",'Code':"",'Value':"",},#ReferenceNumber, |
2692 | + 'Service':{'Code':package_obj.pick_id.ups_service.id and str(package_obj.pick_id.ups_service.shipping_service_code) or "", |
2693 | + 'Description':package_obj.pick_id.ups_service.id and package_obj.pick_id.ups_service.description or ""},#Service |
2694 | + 'InvoiceLineTotal':{'CurrencyCode':"",'MonetaryValue':str(int(package_obj.pick_id.sale_id.amount_total)) or ""},#InvoiceLineTotal |
2695 | + 'ShipmentServiceOptions':{'SaturdayDelivery':"", |
2696 | +# 'COD':{'CODCode':"",'CODFundsCode':"", |
2697 | +# 'CODAmount':{'CurrencyCode':"", |
2698 | +# 'MonetaryValue':"" |
2699 | +# },#CODAmount |
2700 | +# },#COD |
2701 | + 'Notification':[], |
2702 | + 'LabelDelivery':{'LabelLinkIndicator':"", |
2703 | + 'EMailMessage':{'EMailAddress':"mail@mail.com", |
2704 | + 'UndeliverableEMailAddress':"", |
2705 | + 'FromEMailAddress':"mail@mail.com", |
2706 | + 'FromName':"", |
2707 | + 'Memo':"", |
2708 | + 'Subject':"", |
2709 | + 'SubjectCode':""}#EMailMessage |
2710 | + },#LabelDelivery |
2711 | + |
2712 | + 'InternationalForms':self.create_forms(cr, uid, package_obj),#InternationalForms |
2713 | +# 'ReturnOfDocumentIndicator':"", |
2714 | +# 'ImportControlIndicator':"", |
2715 | +# 'LabelMethod':{'Code':"",'Description':"",},#LabelMethod |
2716 | +# 'CommercialInvoiceRemovalIndicator':"", |
2717 | +# 'UPScarbonneutralIndicator':"", |
2718 | +# 'DeliveryConfirmation':{'DCISType':"1",}#DeliveryConfirmation |
2719 | + },#ShipmentServiceOptions, |
2720 | + 'Package':self.get_package(package_obj)## this is done in different file |
2721 | + },#Shipment |
2722 | + 'LabelSpecification':{'LabelPrintMethod':{'Code':"GIF", 'Description':"GIF",}, |
2723 | + 'HTTPUserAgent':"", |
2724 | + 'LabelStockSize':{'Height':"6",'Width':"6"}, |
2725 | + 'LabelImageFormat':{'Code':"GIF",'Description':"GIF"}, |
2726 | + },#LabelSpecification |
2727 | + |
2728 | + },#ShipmentConfirmRequest |
2729 | + } |
2730 | + |
2731 | + |
2732 | + |
2733 | + |
2734 | + comm_inv = data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["ShipmentServiceOptions"]["InternationalForms"]['comm_inv'] |
2735 | + cer_orig = data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["ShipmentServiceOptions"]["InternationalForms"]['cer_orig'] |
2736 | + nafta_cer_orig = data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["ShipmentServiceOptions"]["InternationalForms"]['nafta_cer_orig'] |
2737 | + sed = False #data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["ShipmentServiceOptions"]["InternationalForms"]['sed'] |
2738 | + prod = data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["ShipmentServiceOptions"]["InternationalForms"]['prod'] |
2739 | + |
2740 | + |
2741 | + doc2 = Document() |
2742 | + ShipmentConfirmRequest = doc2.createElement("ShipmentConfirmRequest") |
2743 | + doc2.appendChild(ShipmentConfirmRequest) |
2744 | + |
2745 | + Request = doc2.createElement("Request") |
2746 | + ShipmentConfirmRequest.appendChild(Request) |
2747 | + |
2748 | + RequestAction = doc2.createElement("RequestAction") |
2749 | + ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Request"]["RequestAction"]) |
2750 | + RequestAction.appendChild(ptext) |
2751 | + Request.appendChild(RequestAction) |
2752 | + |
2753 | + RequestOption = doc2.createElement("RequestOption") |
2754 | + ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Request"]["RequestOption"]) |
2755 | + RequestOption.appendChild(ptext) |
2756 | + Request.appendChild(RequestOption) |
2757 | + |
2758 | + TransactionReference = doc2.createElement("TransactionReference") |
2759 | + Request.appendChild(TransactionReference) |
2760 | + |
2761 | + CustomerContext = doc2.createElement("CustomerContext") |
2762 | + ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Request"]["TransactionReference"]['CustomerContext']) |
2763 | + CustomerContext.appendChild(ptext) |
2764 | + TransactionReference.appendChild(CustomerContext) |
2765 | + |
2766 | + Shipment = doc2.createElement("Shipment") |
2767 | + ShipmentConfirmRequest.appendChild(Shipment) |
2768 | + |
2769 | + Description = doc2.createElement("Description") |
2770 | + ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["Description"]) |
2771 | + Description.appendChild(ptext) |
2772 | + Shipment.appendChild(Description) |
2773 | + if package_obj.pick_id.with_ret_service: |
2774 | + ReturnService = doc2.createElement("ReturnService") |
2775 | + Shipment.appendChild(ReturnService) |
2776 | + |
2777 | + |
2778 | + Code = doc2.createElement("Code") |
2779 | + ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["ReturnService"]["Code"]) |
2780 | + Code.appendChild(ptext) |
2781 | + ReturnService.appendChild(Code) |
2782 | + # |
2783 | + # DocumentsOnly = doc2.createElement("DocumentsOnly") |
2784 | + # ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["ReturnService"]["DocumentsOnly"]) |
2785 | + # DocumentsOnly.appendChild(ptext) |
2786 | + # ReturnService.appendChild(DocumentsOnly) |
2787 | + |
2788 | + Shipper = doc2.createElement("Shipper") |
2789 | + Shipment.appendChild(Shipper) |
2790 | + |
2791 | + Name = doc2.createElement("Name") |
2792 | + ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["Shipper"]["Name"]) |
2793 | + Name.appendChild(ptext) |
2794 | + Shipper.appendChild(Name) |
2795 | + |
2796 | + AttentionName = doc2.createElement("AttentionName") |
2797 | + ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["Shipper"]["AttentionName"]) |
2798 | + AttentionName.appendChild(ptext) |
2799 | + Shipper.appendChild(AttentionName) |
2800 | + |
2801 | + ShipperNumber = doc2.createElement("ShipperNumber") |
2802 | + ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["Shipper"]["ShipperNumber"]) |
2803 | + ShipperNumber.appendChild(ptext) |
2804 | + Shipper.appendChild(ShipperNumber) |
2805 | + |
2806 | + TaxIdentificationNumber = doc2.createElement("TaxIdentificationNumber") |
2807 | + ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["Shipper"]["TaxIdentificationNumber"]) |
2808 | + TaxIdentificationNumber.appendChild(ptext) |
2809 | + Shipper.appendChild(TaxIdentificationNumber) |
2810 | + PhoneNumber = doc2.createElement("PhoneNumber") |
2811 | + ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["Shipper"]["PhoneNumber"]) |
2812 | + PhoneNumber.appendChild(ptext) |
2813 | + Shipper.appendChild(PhoneNumber) |
2814 | + |
2815 | + FaxNumber = doc2.createElement("FaxNumber") |
2816 | + ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["Shipper"]["FaxNumber"]) |
2817 | + FaxNumber.appendChild(ptext) |
2818 | + Shipper.appendChild(FaxNumber) |
2819 | + |
2820 | + EMailAddress = doc2.createElement("EMailAddress") |
2821 | + ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["Shipper"]["EMailAddress"]) |
2822 | + EMailAddress.appendChild(ptext) |
2823 | + Shipper.appendChild(EMailAddress) |
2824 | + |
2825 | + #################address |
2826 | + Address = doc2.createElement("Address") |
2827 | + Shipper.appendChild(Address) |
2828 | + |
2829 | + AddressLine1 = doc2.createElement("AddressLine1") |
2830 | + ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["Shipper"]["Address"]["AddressLine1"]) |
2831 | + AddressLine1.appendChild(ptext) |
2832 | + Address.appendChild(AddressLine1) |
2833 | + |
2834 | + AddressLine2 = doc2.createElement("AddressLine2") |
2835 | + ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["Shipper"]["Address"]["AddressLine2"]) |
2836 | + AddressLine2.appendChild(ptext) |
2837 | + Address.appendChild(AddressLine2) |
2838 | + |
2839 | + AddressLine3 = doc2.createElement("AddressLine3") |
2840 | + ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["Shipper"]["Address"]["AddressLine3"]) |
2841 | + AddressLine3.appendChild(ptext) |
2842 | + Address.appendChild(AddressLine3) |
2843 | + |
2844 | + City = doc2.createElement("City") |
2845 | + ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["Shipper"]["Address"]["City"]) |
2846 | + City.appendChild(ptext) |
2847 | + Address.appendChild(City) |
2848 | + |
2849 | + StateProvinceCode = doc2.createElement("StateProvinceCode") |
2850 | + ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["Shipper"]["Address"]["StateProvinceCode"]) |
2851 | + StateProvinceCode.appendChild(ptext) |
2852 | + Address.appendChild(StateProvinceCode) |
2853 | + |
2854 | + PostalCode = doc2.createElement("PostalCode") |
2855 | + ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["Shipper"]["Address"]["PostalCode"]) |
2856 | + PostalCode.appendChild(ptext) |
2857 | + Address.appendChild(PostalCode) |
2858 | + CountryCode = doc2.createElement("CountryCode") |
2859 | + ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["Shipper"]["Address"]["CountryCode"]) |
2860 | + CountryCode.appendChild(ptext) |
2861 | + Address.appendChild(CountryCode) |
2862 | + |
2863 | + ShipTo = doc2.createElement("ShipTo") |
2864 | + Shipment.appendChild(ShipTo) |
2865 | + CompanyName = doc2.createElement("CompanyName") |
2866 | + ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["ShipTo"]["CompanyName"]) |
2867 | + CompanyName.appendChild(ptext) |
2868 | + ShipTo.appendChild(CompanyName) |
2869 | + |
2870 | + AttentionName = doc2.createElement("AttentionName") |
2871 | + ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["ShipTo"]["AttentionName"]) |
2872 | + AttentionName.appendChild(ptext) |
2873 | + ShipTo.appendChild(AttentionName) |
2874 | + |
2875 | + TaxIdentificationNumber = doc2.createElement("TaxIdentificationNumber") |
2876 | + ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["ShipTo"]["TaxIdentificationNumber"]) |
2877 | + TaxIdentificationNumber.appendChild(ptext) |
2878 | + ShipTo.appendChild(TaxIdentificationNumber) |
2879 | + |
2880 | + PhoneNumber = doc2.createElement("PhoneNumber") |
2881 | + ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["ShipTo"]["PhoneNumber"]) |
2882 | + PhoneNumber.appendChild(ptext) |
2883 | + ShipTo.appendChild(PhoneNumber) |
2884 | + |
2885 | + FaxNumber = doc2.createElement("FaxNumber") |
2886 | + ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["ShipTo"]["FaxNumber"]) |
2887 | + FaxNumber.appendChild(ptext) |
2888 | + ShipTo.appendChild(FaxNumber) |
2889 | + |
2890 | + EMailAddress = doc2.createElement("EMailAddress") |
2891 | + ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["ShipTo"]["EMailAddress"]) |
2892 | + EMailAddress.appendChild(ptext) |
2893 | + ShipTo.appendChild(EMailAddress) |
2894 | + |
2895 | + LocationID = doc2.createElement("LocationID") |
2896 | + ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["ShipTo"]["LocationID"]) |
2897 | + LocationID.appendChild(ptext) |
2898 | + ShipTo.appendChild(LocationID) |
2899 | + |
2900 | + Address = doc2.createElement("Address") |
2901 | + ShipTo.appendChild(Address) |
2902 | + AddressLine1 = doc2.createElement("AddressLine1") |
2903 | + ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["ShipTo"]["Address"]["AddressLine1"]) |
2904 | + AddressLine1.appendChild(ptext) |
2905 | + Address.appendChild(AddressLine1) |
2906 | + |
2907 | + AddressLine2 = doc2.createElement("AddressLine2") |
2908 | + ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["ShipTo"]["Address"]["AddressLine2"]) |
2909 | + AddressLine2.appendChild(ptext) |
2910 | + Address.appendChild(AddressLine2) |
2911 | + |
2912 | + AddressLine2 = doc2.createElement("AddressLine3") |
2913 | + ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["ShipTo"]["Address"]["AddressLine3"]) |
2914 | + AddressLine3.appendChild(ptext) |
2915 | + Address.appendChild(AddressLine3) |
2916 | + |
2917 | + City = doc2.createElement("City") |
2918 | + ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["ShipTo"]["Address"]["City"]) |
2919 | + City.appendChild(ptext) |
2920 | + Address.appendChild(City) |
2921 | + |
2922 | + StateProvinceCode = doc2.createElement("StateProvinceCode") |
2923 | + ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["ShipTo"]["Address"]["StateProvinceCode"]) |
2924 | + StateProvinceCode.appendChild(ptext) |
2925 | + Address.appendChild(StateProvinceCode) |
2926 | + |
2927 | + PostalCode = doc2.createElement("PostalCode") |
2928 | + ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["ShipTo"]["Address"]["PostalCode"]) |
2929 | + PostalCode.appendChild(ptext) |
2930 | + Address.appendChild(PostalCode) |
2931 | + |
2932 | + CountryCode = doc2.createElement("CountryCode") |
2933 | + ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["ShipTo"]["Address"]["CountryCode"]) |
2934 | + CountryCode.appendChild(ptext) |
2935 | + Address.appendChild(CountryCode) |
2936 | + if package_obj.pick_id.ship_from: |
2937 | + ShipFrom = doc2.createElement("ShipFrom") |
2938 | + Shipment.appendChild(ShipFrom) |
2939 | + CompanyName = doc2.createElement("CompanyName") |
2940 | + ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["ShipFrom"]["CompanyName"]) |
2941 | + CompanyName.appendChild(ptext) |
2942 | + ShipFrom.appendChild(CompanyName) |
2943 | + |
2944 | + AttentionName = doc2.createElement("AttentionName") |
2945 | + ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["ShipFrom"]["AttentionName"]) |
2946 | + AttentionName.appendChild(ptext) |
2947 | + ShipFrom.appendChild(AttentionName) |
2948 | + |
2949 | + TaxIdentificationNumber = doc2.createElement("TaxIdentificationNumber") |
2950 | + ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["ShipFrom"]["TaxIdentificationNumber"]) |
2951 | + TaxIdentificationNumber.appendChild(ptext) |
2952 | + ShipFrom.appendChild(TaxIdentificationNumber) |
2953 | + |
2954 | + PhoneNumber = doc2.createElement("PhoneNumber") |
2955 | + ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["ShipFrom"]["PhoneNumber"]) |
2956 | + PhoneNumber.appendChild(ptext) |
2957 | + ShipFrom.appendChild(PhoneNumber) |
2958 | + |
2959 | + FaxNumber = doc2.createElement("FaxNumber") |
2960 | + ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["ShipFrom"]["FaxNumber"]) |
2961 | + FaxNumber.appendChild(ptext) |
2962 | + ShipFrom.appendChild(FaxNumber) |
2963 | + |
2964 | + Address = doc2.createElement("Address") |
2965 | + ShipFrom.appendChild(Address) |
2966 | + AddressLine1 = doc2.createElement("AddressLine1") |
2967 | + ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["ShipFrom"]["Address"]["AddressLine1"]) |
2968 | + AddressLine1.appendChild(ptext) |
2969 | + Address.appendChild(AddressLine1) |
2970 | + |
2971 | + AddressLine2 = doc2.createElement("AddressLine2") |
2972 | + ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["ShipFrom"]["Address"]["AddressLine2"]) |
2973 | + AddressLine2.appendChild(ptext) |
2974 | + Address.appendChild(AddressLine2) |
2975 | + |
2976 | + AddressLine3 = doc2.createElement("AddressLine3") |
2977 | + ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["ShipFrom"]["Address"]["AddressLine3"]) |
2978 | + AddressLine3.appendChild(ptext) |
2979 | + Address.appendChild(AddressLine3) |
2980 | + |
2981 | + City = doc2.createElement("City") |
2982 | + ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["ShipFrom"]["Address"]["City"]) |
2983 | + City.appendChild(ptext) |
2984 | + Address.appendChild(City) |
2985 | + |
2986 | + StateProvinceCode = doc2.createElement("StateProvinceCode") |
2987 | + ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["ShipFrom"]["Address"]["StateProvinceCode"]) |
2988 | + StateProvinceCode.appendChild(ptext) |
2989 | + Address.appendChild(StateProvinceCode) |
2990 | + |
2991 | +# PostalCode = doc2.createElement("PostalCode") |
2992 | +# ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["ShipFrom"]["Address"]["PostalCode"]) |
2993 | +# PostalCode.appendChild(ptext) |
2994 | +# Address.appendChild(PostalCode) |
2995 | + |
2996 | + CountryCode = doc2.createElement("CountryCode") |
2997 | + ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["ShipFrom"]["Address"]["CountryCode"]) |
2998 | + CountryCode.appendChild(ptext) |
2999 | + Address.appendChild(CountryCode) |
3000 | + |
3001 | + |
3002 | +################### |
3003 | + if comm_inv or nafta_cer_orig: |
3004 | + SoldTo = doc2.createElement("SoldTo") |
3005 | + Shipment.appendChild(SoldTo) |
3006 | +# if data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["SoldTo"]["Option"] != ' ': |
3007 | + Option = doc2.createElement("Option") |
3008 | + ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["SoldTo"]["Option"]) |
3009 | + Option.appendChild(ptext) |
3010 | + SoldTo.appendChild(Option) |
3011 | + |
3012 | + CompanyName = doc2.createElement("CompanyName") |
3013 | + ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["SoldTo"]["CompanyName"]) |
3014 | + CompanyName.appendChild(ptext) |
3015 | + SoldTo.appendChild(CompanyName) |
3016 | +# else: |
3017 | + CompanyName = doc2.createElement("CompanyName") |
3018 | + ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["SoldTo"]["CompanyName"]) |
3019 | + CompanyName.appendChild(ptext) |
3020 | + SoldTo.appendChild(CompanyName) |
3021 | + |
3022 | + AttentionName = doc2.createElement("AttentionName") |
3023 | + ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["SoldTo"]["AttentionName"]) |
3024 | + AttentionName.appendChild(ptext) |
3025 | + SoldTo.appendChild(AttentionName) |
3026 | + |
3027 | + TaxIdentificationNumber = doc2.createElement("TaxIdentificationNumber") |
3028 | + ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["SoldTo"]["TaxIdentificationNumber"]) |
3029 | + TaxIdentificationNumber.appendChild(ptext) |
3030 | + SoldTo.appendChild(TaxIdentificationNumber) |
3031 | + |
3032 | + PhoneNumber = doc2.createElement("PhoneNumber") |
3033 | + ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["SoldTo"]["PhoneNumber"]) |
3034 | + PhoneNumber.appendChild(ptext) |
3035 | + SoldTo.appendChild(PhoneNumber) |
3036 | + |
3037 | + |
3038 | + Address = doc2.createElement("Address") |
3039 | + SoldTo.appendChild(Address) |
3040 | + AddressLine1 = doc2.createElement("AddressLine1") |
3041 | + ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["SoldTo"]["Address"]["AddressLine1"]) |
3042 | + AddressLine1.appendChild(ptext) |
3043 | + Address.appendChild(AddressLine1) |
3044 | + |
3045 | + AddressLine2 = doc2.createElement("AddressLine2") |
3046 | + ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["SoldTo"]["Address"]["AddressLine2"]) |
3047 | + AddressLine2.appendChild(ptext) |
3048 | + Address.appendChild(AddressLine2) |
3049 | + |
3050 | + |
3051 | + City = doc2.createElement("City") |
3052 | + ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["SoldTo"]["Address"]["City"]) |
3053 | + City.appendChild(ptext) |
3054 | + Address.appendChild(City) |
3055 | + |
3056 | + StateProvinceCode = doc2.createElement("StateProvinceCode") |
3057 | + ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["SoldTo"]["Address"]["StateProvinceCode"]) |
3058 | + StateProvinceCode.appendChild(ptext) |
3059 | + Address.appendChild(StateProvinceCode) |
3060 | + |
3061 | + PostalCode = doc2.createElement("PostalCode") |
3062 | + ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["SoldTo"]["Address"]["PostalCode"]) |
3063 | + PostalCode.appendChild(ptext) |
3064 | + Address.appendChild(PostalCode) |
3065 | + |
3066 | + CountryCode = doc2.createElement("CountryCode") |
3067 | + ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["SoldTo"]["Address"]["CountryCode"]) |
3068 | + CountryCode.appendChild(ptext) |
3069 | + Address.appendChild(CountryCode) |
3070 | + |
3071 | +######################### |
3072 | + PaymentInformation = doc2.createElement("PaymentInformation") |
3073 | + Shipment.appendChild(PaymentInformation) |
3074 | + Prepaid = doc2.createElement("Prepaid") |
3075 | + PaymentInformation.appendChild(Prepaid) |
3076 | + |
3077 | + BillShipper = doc2.createElement("BillShipper") |
3078 | + Prepaid.appendChild(BillShipper) |
3079 | + |
3080 | + AccountNumber = doc2.createElement("AccountNumber") |
3081 | + ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["PaymentInformation"]["Prepaid"]["BillShipper"]["AccountNumber"]) |
3082 | + AccountNumber.appendChild(ptext) |
3083 | + BillShipper.appendChild(AccountNumber) |
3084 | + |
3085 | + # CreditCard = doc2.createElement("CreditCard") |
3086 | + # BillShipper.appendChild(CreditCard) |
3087 | + # Type = doc2.createElement("Type") |
3088 | + # ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["PaymentInformation"]["Prepaid"]["BillShipper"]["CreditCard"]["Type"]) |
3089 | + # Type.appendChild(ptext) |
3090 | + # CreditCard.appendChild(Type) |
3091 | + # |
3092 | + # ExpirationDate = doc2.createElement("ExpirationDate") |
3093 | + # ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["PaymentInformation"]["Prepaid"]["BillShipper"]["CreditCard"]["ExpirationDate"]) |
3094 | + # ExpirationDate.appendChild(ptext) |
3095 | + # CreditCard.appendChild(ExpirationDate) |
3096 | + # |
3097 | + # Number = doc2.createElement("Number") |
3098 | + # ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["PaymentInformation"]["Prepaid"]["BillShipper"]["CreditCard"]["Number"]) |
3099 | + # Number.appendChild(ptext) |
3100 | + # CreditCard.appendChild(Number) |
3101 | + # |
3102 | + # SecurityCode = doc2.createElement("SecurityCode") |
3103 | + # ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["PaymentInformation"]["Prepaid"]["BillShipper"]["CreditCard"]["SecurityCode"]) |
3104 | + # SecurityCode.appendChild(ptext) |
3105 | + # CreditCard.appendChild(SecurityCode) |
3106 | + # |
3107 | + # |
3108 | + # Address = doc2.createElement("Address") |
3109 | + # CreditCard.appendChild(Address) |
3110 | + # AddressLine1 = doc2.createElement("AddressLine1") |
3111 | + # ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["PaymentInformation"]["Prepaid"]["BillShipper"]["CreditCard"]["Address"]["AddressLine1"]) |
3112 | + # AddressLine1.appendChild(ptext) |
3113 | + # Address.appendChild(AddressLine1) |
3114 | + # |
3115 | + # AddressLine2 = doc2.createElement("AddressLine2") |
3116 | + # ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["PaymentInformation"]["Prepaid"]["BillShipper"]["CreditCard"]["Address"]["AddressLine2"]) |
3117 | + # AddressLine2.appendChild(ptext) |
3118 | + # Address.appendChild(AddressLine2) |
3119 | + # |
3120 | + # AddressLine3 = doc2.createElement("AddressLine3") |
3121 | + # ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["PaymentInformation"]["Prepaid"]["BillShipper"]["CreditCard"]["Address"]["AddressLine3"]) |
3122 | + # AddressLine3.appendChild(ptext) |
3123 | + # Address.appendChild(AddressLine3) |
3124 | + # |
3125 | + # |
3126 | + # City = doc2.createElement("City") |
3127 | + # ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["PaymentInformation"]["Prepaid"]["BillShipper"]["CreditCard"]["Address"]["City"]) |
3128 | + # City.appendChild(ptext) |
3129 | + # Address.appendChild(City) |
3130 | + # |
3131 | + # StateProvinceCode = doc2.createElement("StateProvinceCode") |
3132 | + # ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["PaymentInformation"]["Prepaid"]["BillShipper"]["CreditCard"]["Address"]["StateProvinceCode"]) |
3133 | + # StateProvinceCode.appendChild(ptext) |
3134 | + # Address.appendChild(StateProvinceCode) |
3135 | + # |
3136 | + # PostalCode = doc2.createElement("PostalCode") |
3137 | + # ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["PaymentInformation"]["Prepaid"]["BillShipper"]["CreditCard"]["Address"]["PostalCode"]) |
3138 | + # PostalCode.appendChild(ptext) |
3139 | + # Address.appendChild(PostalCode) |
3140 | + # |
3141 | + # CountryCode = doc2.createElement("CountryCode") |
3142 | + # ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["PaymentInformation"]["Prepaid"]["BillShipper"]["CreditCard"]["Address"]["CountryCode"]) |
3143 | + # PostalCode.appendChild(ptext) |
3144 | + # Address.appendChild(CountryCode) |
3145 | + |
3146 | + |
3147 | + |
3148 | + |
3149 | + # BillThirdParty = doc2.createElement("BillThirdParty") |
3150 | + # PaymentInformation.appendChild(BillThirdParty) |
3151 | + # BillThirdPartyShipper = doc2.createElement("BillThirdPartyShipper") |
3152 | + # BillThirdParty.appendChild(BillThirdPartyShipper) |
3153 | + # |
3154 | + # AccountNumber = doc2.createElement("AccountNumber") |
3155 | + # ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["PaymentInformation"]["BillThirdParty"]['BillThirdPartyShipper']['AccountNumber']) |
3156 | + # AccountNumber.appendChild(ptext) |
3157 | + # BillThirdPartyShipper.appendChild(AccountNumber) |
3158 | + # |
3159 | + # ThirdParty = doc2.createElement("ThirdParty") |
3160 | + # BillThirdPartyShipper.appendChild(ThirdParty) |
3161 | + # Address = doc2.createElement("Address") |
3162 | + # ThirdParty.appendChild(Address) |
3163 | + # |
3164 | + # PostalCode = doc2.createElement("PostalCode") |
3165 | + # ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["PaymentInformation"]["BillThirdParty"]['BillThirdPartyShipper']['ThirdParty']['Address']['PostalCode']) |
3166 | + # PostalCode.appendChild(ptext) |
3167 | + # Address.appendChild(PostalCode) |
3168 | + # |
3169 | + # CountryCode = doc2.createElement("CountryCode") |
3170 | + # ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["PaymentInformation"]["BillThirdParty"]['BillThirdPartyShipper']['ThirdParty']['Address']['CountryCode']) |
3171 | + # CountryCode.appendChild(ptext) |
3172 | + # Address.appendChild(CountryCode) |
3173 | + |
3174 | + |
3175 | + |
3176 | + # FreightCollect = doc2.createElement("FreightCollect") |
3177 | + # PaymentInformation.appendChild(FreightCollect) |
3178 | + # BillReceiver = doc2.createElement("BillReceiver") |
3179 | + # FreightCollect.appendChild(BillReceiver) |
3180 | + # AccountNumber = doc2.createElement("AccountNumber") |
3181 | + # ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["PaymentInformation"]["FreightCollect"]["BillReceiver"]["AccountNumber"]) |
3182 | + # AccountNumber.appendChild(ptext) |
3183 | + # BillReceiver.appendChild(AccountNumber) |
3184 | + # |
3185 | + # Address = doc2.createElement("Address") |
3186 | + # BillReceiver.appendChild(Address) |
3187 | + # PostalCode = doc2.createElement("PostalCode") |
3188 | + # ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["PaymentInformation"]["FreightCollect"]["BillReceiver"]["Address"]["PostalCode"]) |
3189 | + # AccountNumber.appendChild(ptext) |
3190 | + # Address.appendChild(PostalCode) |
3191 | + |
3192 | + # ConsigneeBilled = doc2.createElement("ConsigneeBilled") |
3193 | + # ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["PaymentInformation"]["ConsigneeBilled"]) |
3194 | + # ConsigneeBilled.appendChild(ptext) |
3195 | + # PaymentInformation.appendChild(ConsigneeBilled) |
3196 | + |
3197 | + |
3198 | + |
3199 | + |
3200 | + # ItemizedPaymentInformation = doc2.createElement("ItemizedPaymentInformation") |
3201 | + # Shipment.appendChild(ItemizedPaymentInformation) |
3202 | + # ShipmentCharge = doc2.createElement("ShipmentCharge") |
3203 | + # ItemizedPaymentInformation.appendChild(ShipmentCharge) |
3204 | + # Type = doc2.createElement("Type") |
3205 | + # ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["ItemizedPaymentInformation"]["ShipmentCharge"]["Type"]) |
3206 | + # Type.appendChild(ptext) |
3207 | + # ShipmentCharge.appendChild(Type) |
3208 | + # |
3209 | + # BillShipper = doc2.createElement("BillShipper") |
3210 | + # ShipmentCharge.appendChild(BillShipper) |
3211 | + # |
3212 | + # AccountNumber = doc2.createElement("AccountNumber") |
3213 | + # ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["ItemizedPaymentInformation"]["ShipmentCharge"]["BillShipper"]["AccountNumber"]) |
3214 | + # AccountNumber.appendChild(ptext) |
3215 | + # BillShipper.appendChild(AccountNumber) |
3216 | + # |
3217 | + # CreditCard = doc2.createElement("CreditCard") |
3218 | + # BillShipper.appendChild(CreditCard) |
3219 | + # |
3220 | + # Type = doc2.createElement("Type") |
3221 | + # ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["ItemizedPaymentInformation"]["ShipmentCharge"]["BillShipper"]["CreditCard"]["Type"]) |
3222 | + # Type.appendChild(ptext) |
3223 | + # CreditCard.appendChild(Type) |
3224 | + # |
3225 | + # ExpirationDate = doc2.createElement("ExpirationDate") |
3226 | + # ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["ItemizedPaymentInformation"]["ShipmentCharge"]["BillShipper"]["CreditCard"]["ExpirationDate"]) |
3227 | + # ExpirationDate.appendChild(ptext) |
3228 | + # CreditCard.appendChild(ExpirationDate) |
3229 | + # |
3230 | + # SecurityCode = doc2.createElement("SecurityCode") |
3231 | + # ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["ItemizedPaymentInformation"]["ShipmentCharge"]["BillShipper"]["CreditCard"]["SecurityCode"]) |
3232 | + # SecurityCode.appendChild(ptext) |
3233 | + # CreditCard.appendChild(SecurityCode) |
3234 | + # |
3235 | + # Address = doc2.createElement("Address") |
3236 | + # CreditCard.appendChild(Address) |
3237 | + # AddressLine1 = doc2.createElement("AddressLine1") |
3238 | + # ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["ItemizedPaymentInformation"]["ShipmentCharge"]["BillShipper"]['CreditCard']["Address"]["AddressLine1"]) |
3239 | + # AddressLine1.appendChild(ptext) |
3240 | + # Address.appendChild(AddressLine1) |
3241 | + # |
3242 | + # AddressLine2 = doc2.createElement("AddressLine2") |
3243 | + # ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["ItemizedPaymentInformation"]["ShipmentCharge"]["BillShipper"]['CreditCard']["Address"]["AddressLine2"]) |
3244 | + # AddressLine2.appendChild(ptext) |
3245 | + # Address.appendChild(AddressLine2) |
3246 | + # |
3247 | + # AddressLine3 = doc2.createElement("AddressLine3") |
3248 | + # ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["ItemizedPaymentInformation"]["ShipmentCharge"]["BillShipper"]['CreditCard']["Address"]["AddressLine3"]) |
3249 | + # AddressLine3.appendChild(ptext) |
3250 | + # Address.appendChild(AddressLine3) |
3251 | + # |
3252 | + # City = doc2.createElement("City") |
3253 | + # ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["ItemizedPaymentInformation"]["ShipmentCharge"]["BillShipper"]['CreditCard']["Address"]["City"]) |
3254 | + # City.appendChild(ptext) |
3255 | + # Address.appendChild(City) |
3256 | + # |
3257 | + # StateProvinceCode = doc2.createElement("StateProvinceCode") |
3258 | + # ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["ItemizedPaymentInformation"]["ShipmentCharge"]["BillShipper"]['CreditCard']["Address"]["StateProvinceCode"]) |
3259 | + # StateProvinceCode.appendChild(ptext) |
3260 | + # Address.appendChild(StateProvinceCode) |
3261 | + # |
3262 | + # PostalCode = doc2.createElement("PostalCode") |
3263 | + # ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["ItemizedPaymentInformation"]["ShipmentCharge"]["BillShipper"]['CreditCard']["Address"]["PostalCode"]) |
3264 | + # PostalCode.appendChild(ptext) |
3265 | + # Address.appendChild(PostalCode) |
3266 | + # |
3267 | + # CountryCode = doc2.createElement("CountryCode") |
3268 | + # ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["ItemizedPaymentInformation"]["ShipmentCharge"]["BillShipper"]['CreditCard']["Address"]["CountryCode"]) |
3269 | + # CountryCode.appendChild(ptext) |
3270 | + # Address.appendChild(CountryCode) |
3271 | + # |
3272 | + # BillReceiver = doc2.createElement("BillReceiver") |
3273 | + # ShipmentCharge.appendChild(BillReceiver) |
3274 | + # |
3275 | + # AccountNumber = doc2.createElement("AccountNumber") |
3276 | + # ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["ItemizedPaymentInformation"]["ShipmentCharge"]["BillReceiver"]["AccountNumber"]) |
3277 | + # AccountNumber.appendChild(ptext) |
3278 | + # BillReceiver.appendChild(AccountNumber) |
3279 | + # |
3280 | + # Address = doc2.createElement("Address") |
3281 | + # BillReceiver.appendChild(Address) |
3282 | + # PostalCode = doc2.createElement("PostalCode") |
3283 | + # ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["ItemizedPaymentInformation"]["ShipmentCharge"]["BillReceiver"]["Address"]["PostalCode"]) |
3284 | + # PostalCode.appendChild(ptext) |
3285 | + # Address.appendChild(PostalCode) |
3286 | + # |
3287 | + # |
3288 | + # BillThirdParty = doc2.createElement("BillThirdParty") |
3289 | + # ShipmentCharge.appendChild(BillThirdParty) |
3290 | + # BillThirdPartyShipper = doc2.createElement("BillThirdPartyShipper") |
3291 | + # BillThirdParty.appendChild(BillThirdPartyShipper) |
3292 | + # |
3293 | + # AccountNumber = doc2.createElement("AccountNumber") |
3294 | + # ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["ItemizedPaymentInformation"]["ShipmentCharge"]["BillThirdParty"]["BillThirdPartyShipper"]["AccountNumber"]) |
3295 | + # AccountNumber.appendChild(ptext) |
3296 | + # BillThirdPartyShipper.appendChild(AccountNumber) |
3297 | + # |
3298 | + # ThirdParty = doc2.createElement("ThirdParty") |
3299 | + # BillThirdPartyShipper.appendChild(ThirdParty) |
3300 | + # Address = doc2.createElement("Address") |
3301 | + # ThirdParty.appendChild(Address) |
3302 | + # PostalCode = doc2.createElement("PostalCode") |
3303 | + # ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["ItemizedPaymentInformation"]["ShipmentCharge"]["BillThirdParty"]["BillThirdPartyShipper"]["ThirdParty"]["Address"]["PostalCode"]) |
3304 | + # PostalCode.appendChild(ptext) |
3305 | + # Address.appendChild(PostalCode) |
3306 | + # |
3307 | + # CountryCode = doc2.createElement("CountryCode") |
3308 | + # ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["ItemizedPaymentInformation"]["ShipmentCharge"]["BillThirdParty"]["BillThirdPartyShipper"]["ThirdParty"]["Address"]["CountryCode"]) |
3309 | + # CountryCode.appendChild(ptext) |
3310 | + # Address.appendChild(CountryCode) |
3311 | + # |
3312 | + # |
3313 | + # BillThirdPartyConsignee = doc2.createElement("BillThirdPartyConsignee") |
3314 | + # BillThirdParty.appendChild(BillThirdPartyConsignee) |
3315 | + # |
3316 | + # AccountNumber = doc2.createElement("AccountNumber") |
3317 | + # ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["ItemizedPaymentInformation"]["ShipmentCharge"]["BillThirdParty"]["BillThirdPartyConsignee"]["AccountNumber"]) |
3318 | + # AccountNumber.appendChild(ptext) |
3319 | + # BillThirdPartyConsignee.appendChild(AccountNumber) |
3320 | + # |
3321 | + # ThirdParty = doc2.createElement("ThirdParty") |
3322 | + # BillThirdPartyConsignee.appendChild(ThirdParty) |
3323 | + # Address = doc2.createElement("Address") |
3324 | + # ThirdParty.appendChild(Address) |
3325 | + # PostalCode = doc2.createElement("PostalCode") |
3326 | + # ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["ItemizedPaymentInformation"]["ShipmentCharge"]["BillThirdParty"]["BillThirdPartyConsignee"]["ThirdParty"]["Address"]["PostalCode"]) |
3327 | + # PostalCode.appendChild(ptext) |
3328 | + # Address.appendChild(PostalCode) |
3329 | + # |
3330 | + # CountryCode = doc2.createElement("CountryCode") |
3331 | + # ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["ItemizedPaymentInformation"]["ShipmentCharge"]["BillThirdParty"]["BillThirdPartyConsignee"]["ThirdParty"]["Address"]["CountryCode"]) |
3332 | + # CountryCode.appendChild(ptext) |
3333 | + # Address.appendChild(CountryCode) |
3334 | + # |
3335 | + # ConsigneeBilled = doc2.createElement("ConsigneeBilled") |
3336 | + # ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["ItemizedPaymentInformation"]["ShipmentCharge"]["ConsigneeBilled"]) |
3337 | + # ConsigneeBilled.appendChild(ptext) |
3338 | + # ShipmentCharge.appendChild(ConsigneeBilled) |
3339 | + # |
3340 | + # SplitDutyVATIndicator = doc2.createElement("SplitDutyVATIndicator") |
3341 | + # ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["ItemizedPaymentInformation"]["SplitDutyVATIndicator"]) |
3342 | + # SplitDutyVATIndicator.appendChild(ptext) |
3343 | + # ItemizedPaymentInformation.appendChild(SplitDutyVATIndicator) |
3344 | + |
3345 | + GoodsNotInFreeCirculationIndicator = doc2.createElement("GoodsNotInFreeCirculationIndicator") |
3346 | + # ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["GoodsNotInFreeCirculationIndicator"]) |
3347 | + # GoodsNotInFreeCirculationIndicator.appendChild(ptext) |
3348 | + Shipment.appendChild(GoodsNotInFreeCirculationIndicator) |
3349 | + |
3350 | + RateInformation = doc2.createElement("RateInformation") |
3351 | + Shipment.appendChild(RateInformation) |
3352 | + NegotiatedRatesIndicator = doc2.createElement("NegotiatedRatesIndicator") |
3353 | + # ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["RateInformation"]["NegotiatedRatesIndicator"]) |
3354 | + # NegotiatedRatesIndicator.appendChild(ptext) |
3355 | + RateInformation.appendChild(NegotiatedRatesIndicator) |
3356 | + |
3357 | + # MovementReferenceNumber = doc2.createElement("MovementReferenceNumber") |
3358 | + # ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["MovementReferenceNumber"]) |
3359 | + # MovementReferenceNumber.appendChild(ptext) |
3360 | + # Shipment.appendChild(MovementReferenceNumber) |
3361 | + |
3362 | + # ReferenceNumber = doc2.createElement("ReferenceNumber") |
3363 | + # Shipment.appendChild(ReferenceNumber) |
3364 | + # BarCodeIndicator = doc2.createElement("BarCodeIndicator") |
3365 | + # ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["ReferenceNumber"]["BarCodeIndicator"]) |
3366 | + # BarCodeIndicator.appendChild(ptext) |
3367 | + # ReferenceNumber.appendChild(BarCodeIndicator) |
3368 | + # |
3369 | + # Code = doc2.createElement("Code") |
3370 | + # ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["ReferenceNumber"]["Code"]) |
3371 | + # Code.appendChild(ptext) |
3372 | + # ReferenceNumber.appendChild(Code) |
3373 | + # |
3374 | + # Value = doc2.createElement("Value") |
3375 | + # ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["ReferenceNumber"]["Value"]) |
3376 | + # Value.appendChild(ptext) |
3377 | + # ReferenceNumber.appendChild(Value) |
3378 | + |
3379 | + Service = doc2.createElement("Service") |
3380 | + Shipment.appendChild(Service) |
3381 | + Code = doc2.createElement("Code") |
3382 | + ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["Service"]["Code"]) |
3383 | + Code.appendChild(ptext) |
3384 | + Service.appendChild(Code) |
3385 | + Description = doc2.createElement("Description") |
3386 | + ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["Service"]["Description"]) |
3387 | + Description.appendChild(ptext) |
3388 | + Service.appendChild(Description) |
3389 | + |
3390 | + if (package_obj.pick_id.ship_from and package_obj.pick_id.ship_from_address.id and package_obj.pick_id.ship_from_address.country_id.code == 'US' or package_obj.pick_id.shipper.id and package_obj.pick_id.shipper.address.id and package_obj.pick_id.shipper.address.country_id.id and package_obj.pick_id.shipper.address.country_id.code == 'US') and package_obj.pick_id.address_id.id and package_obj.pick_id.address_id.country_id.code in ('PR','CA'): |
3391 | + InvoiceLineTotal = doc2.createElement("InvoiceLineTotal") |
3392 | + Shipment.appendChild(InvoiceLineTotal) |
3393 | + |
3394 | + # CurrencyCode = doc2.createElement("CurrencyCode") |
3395 | + # ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["InvoiceLineTotal"]["CurrencyCode"]) |
3396 | + # CurrencyCode.appendChild(ptext) |
3397 | + # InvoiceLineTotal.appendChild(CurrencyCode) |
3398 | + |
3399 | + MonetaryValue = doc2.createElement("MonetaryValue") |
3400 | + ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["InvoiceLineTotal"]["MonetaryValue"]) |
3401 | + MonetaryValue.appendChild(ptext) |
3402 | + InvoiceLineTotal.appendChild(MonetaryValue) |
3403 | + |
3404 | + |
3405 | + ShipmentServiceOptions = doc2.createElement("ShipmentServiceOptions") |
3406 | + Shipment.appendChild(ShipmentServiceOptions) |
3407 | + if package_obj.pick_id.sat_delivery: |
3408 | + SaturdayDelivery = doc2.createElement("SaturdayDelivery") |
3409 | + # ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["ShipmentServiceOptions"]["SaturdayDelivery"]) |
3410 | + # SaturdayDelivery.appendChild(ptext) |
3411 | + ShipmentServiceOptions.appendChild(SaturdayDelivery) |
3412 | + # COD = doc2.createElement("COD") |
3413 | + # ShipmentServiceOptions.appendChild(COD) |
3414 | + # CODCode = doc2.createElement("CODCode") |
3415 | + # ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["ShipmentServiceOptions"]["COD"]["CODCode"]) |
3416 | + # CODCode.appendChild(ptext) |
3417 | + # COD.appendChild(CODCode) |
3418 | + # |
3419 | + # CODFundsCode = doc2.createElement("CODFundsCode") |
3420 | + # ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["ShipmentServiceOptions"]["COD"]["CODFundsCode"]) |
3421 | + # CODFundsCode.appendChild(ptext) |
3422 | + # COD.appendChild(CODFundsCode) |
3423 | + # |
3424 | + # CODAmount = doc2.createElement("CODAmount") |
3425 | + # COD.appendChild(CODAmount) |
3426 | + # CurrencyCode = doc2.createElement("CurrencyCode") |
3427 | + # ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["ShipmentServiceOptions"]["COD"]["CODAmount"]["CurrencyCode"]) |
3428 | + # CurrencyCode.appendChild(ptext) |
3429 | + # CODAmount.appendChild(CurrencyCode) |
3430 | + # |
3431 | + # MonetaryValue = doc2.createElement("MonetaryValue") |
3432 | + # ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["ShipmentServiceOptions"]["COD"]["CODAmount"]["MonetaryValue"]) |
3433 | + # MonetaryValue.appendChild(ptext) |
3434 | + # CODAmount.appendChild(MonetaryValue) |
3435 | + |
3436 | + Notification_count = len(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["ShipmentServiceOptions"]["Notification"]) |
3437 | + for i in range (0,Notification_count): |
3438 | + Notification = doc2.createElement("Notification") |
3439 | + ShipmentServiceOptions.appendChild(Notification) |
3440 | + NotificationCode = doc2.createElement("NotificationCode") |
3441 | + ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["ShipmentServiceOptions"]["Notification"][i]["NotificationCode"]) |
3442 | + NotificationCode.appendChild(ptext) |
3443 | + Notification.appendChild(NotificationCode) |
3444 | + EMailMessage = doc2.createElement("EMailMessage") |
3445 | + Notification.appendChild(EMailMessage) |
3446 | + UndeliverableEMailAddress = doc2.createElement("UndeliverableEMailAddress") |
3447 | + ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["ShipmentServiceOptions"]["Notification"][i]["EMailMessage"]["UndeliverableEMailAddress"]) |
3448 | + UndeliverableEMailAddress.appendChild(ptext) |
3449 | + EMailMessage.appendChild(UndeliverableEMailAddress) |
3450 | + |
3451 | + EMailAddress = doc2.createElement("EMailAddress") |
3452 | + ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["ShipmentServiceOptions"]["Notification"][i]["EMailMessage"]["EMailAddress"]) |
3453 | + EMailAddress.appendChild(ptext) |
3454 | + EMailMessage.appendChild(EMailAddress) |
3455 | + |
3456 | + FromEMailAddress = doc2.createElement("FromEMailAddress") |
3457 | + ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["ShipmentServiceOptions"]["Notification"][i]["EMailMessage"]["FromEMailAddress"]) |
3458 | + FromEMailAddress.appendChild(ptext) |
3459 | + EMailMessage.appendChild(FromEMailAddress) |
3460 | + |
3461 | + FromName = doc2.createElement("FromName") |
3462 | + ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["ShipmentServiceOptions"]["Notification"][i]["EMailMessage"]["FromName"]) |
3463 | + FromName.appendChild(ptext) |
3464 | + EMailMessage.appendChild(FromName) |
3465 | + |
3466 | + Memo = doc2.createElement("Memo") |
3467 | + ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["ShipmentServiceOptions"]["Notification"][i]["EMailMessage"]["Memo"]) |
3468 | + Memo.appendChild(ptext) |
3469 | + EMailMessage.appendChild(Memo) |
3470 | + |
3471 | + Subject = doc2.createElement("Subject") |
3472 | + ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["ShipmentServiceOptions"]["Notification"][i]["EMailMessage"]["Subject"]) |
3473 | + Subject.appendChild(ptext) |
3474 | + EMailMessage.appendChild(Subject) |
3475 | + |
3476 | + SubjectCode = doc2.createElement("SubjectCode") |
3477 | + ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["ShipmentServiceOptions"]["Notification"][i]["EMailMessage"]["SubjectCode"]) |
3478 | + SubjectCode.appendChild(ptext) |
3479 | + EMailMessage.appendChild(SubjectCode) |
3480 | + ##//////////////////////end for loop in code |
3481 | + if package_obj.pick_id.with_ret_service: |
3482 | + LabelDelivery = doc2.createElement("LabelDelivery") |
3483 | + ShipmentServiceOptions.appendChild(LabelDelivery) |
3484 | + LabelLinkIndicator = doc2.createElement("LabelLinkIndicator") |
3485 | + # ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["ShipmentServiceOptions"]["LabelDelivery"]["LabelLinkIndicator"]) |
3486 | + # LabelLinkIndicator.appendChild(ptext) |
3487 | + LabelDelivery.appendChild(LabelLinkIndicator) |
3488 | + # EMailMessage = doc2.createElement("EMailMessage") |
3489 | + # LabelDelivery.appendChild(EMailMessage) |
3490 | + # UndeliverableEMailAddress = doc2.createElement("UndeliverableEMailAddress") |
3491 | + # ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["ShipmentServiceOptions"]["LabelDelivery"]["EMailMessage"]["UndeliverableEMailAddress"]) |
3492 | + # UndeliverableEMailAddress.appendChild(ptext) |
3493 | + # EMailMessage.appendChild(UndeliverableEMailAddress) |
3494 | + # |
3495 | + # |
3496 | + # EMailAddress = doc2.createElement("EMailAddress") |
3497 | + # ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["ShipmentServiceOptions"]["LabelDelivery"]["EMailMessage"]["EMailAddress"]) |
3498 | + # EMailAddress.appendChild(ptext) |
3499 | + # EMailMessage.appendChild(EMailAddress) |
3500 | + # |
3501 | + # FromEMailAddress = doc2.createElement("FromEMailAddress") |
3502 | + # ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["ShipmentServiceOptions"]["LabelDelivery"]["EMailMessage"]["FromEMailAddress"]) |
3503 | + # FromEMailAddress.appendChild(ptext) |
3504 | + # EMailMessage.appendChild(FromEMailAddress) |
3505 | + # |
3506 | + # FromName = doc2.createElement("FromName") |
3507 | + # ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["ShipmentServiceOptions"]["LabelDelivery"]["EMailMessage"]["FromName"]) |
3508 | + # FromName.appendChild(ptext) |
3509 | + # EMailMessage.appendChild(FromName) |
3510 | + # |
3511 | + # Memo = doc2.createElement("Memo") |
3512 | + # ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["ShipmentServiceOptions"]["LabelDelivery"]["EMailMessage"]["Memo"]) |
3513 | + # Memo.appendChild(ptext) |
3514 | + # EMailMessage.appendChild(Memo) |
3515 | + # |
3516 | + # Subject = doc2.createElement("Subject") |
3517 | + # ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["ShipmentServiceOptions"]["LabelDelivery"]["EMailMessage"]["Subject"]) |
3518 | + # Subject.appendChild(ptext) |
3519 | + # EMailMessage.appendChild(Subject) |
3520 | + # |
3521 | + # SubjectCode = doc2.createElement("SubjectCode") |
3522 | + # ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["ShipmentServiceOptions"]["LabelDelivery"]["EMailMessage"]["SubjectCode"]) |
3523 | + # SubjectCode.appendChild(ptext) |
3524 | + # EMailMessage.appendChild(SubjectCode) |
3525 | + |
3526 | + |
3527 | + |
3528 | + if comm_inv or cer_orig or nafta_cer_orig or sed: |
3529 | + InternationalForms = doc2.createElement("InternationalForms") |
3530 | + ShipmentServiceOptions.appendChild(InternationalForms) |
3531 | + |
3532 | +# if cer_orig or nafta_cer_orig or sed: |
3533 | +# AdditionalDocumentIndicator = doc2.createElement("AdditionalDocumentIndicator") |
3534 | +# InternationalForms.appendChild(AdditionalDocumentIndicator) |
3535 | + |
3536 | + if comm_inv: |
3537 | + FormType = doc2.createElement("FormType") |
3538 | + ptext = doc1.createTextNode(comm_inv['FormType']) |
3539 | + FormType.appendChild(ptext) |
3540 | + InternationalForms.appendChild(FormType) |
3541 | + if cer_orig: |
3542 | + FormType = doc2.createElement("FormType") |
3543 | + ptext = doc1.createTextNode(cer_orig['FormType']) |
3544 | + FormType.appendChild(ptext) |
3545 | + InternationalForms.appendChild(FormType) |
3546 | + if nafta_cer_orig: |
3547 | + FormType = doc2.createElement("FormType") |
3548 | + ptext = doc1.createTextNode(nafta_cer_orig['FormType']) |
3549 | + FormType.appendChild(ptext) |
3550 | + InternationalForms.appendChild(FormType) |
3551 | +# if sed: |
3552 | +# FormType = doc2.createElement("FormType") |
3553 | +# ptext = doc1.createTextNode(sed['FormType']) |
3554 | +# FormType.appendChild(ptext) |
3555 | +# InternationalForms.appendChild(FormType) |
3556 | +# |
3557 | +# SEDFilingOption = doc2.createElement("SEDFilingOption") |
3558 | +# ptext = doc1.createTextNode(sed['SEDFilingOption']) |
3559 | +# SEDFilingOption.appendChild(ptext) |
3560 | +# InternationalForms.appendChild(SEDFilingOption) |
3561 | + |
3562 | + if sed or nafta_cer_orig: |
3563 | + Contacts = doc2.createElement("Contacts") |
3564 | + InternationalForms.appendChild(Contacts) |
3565 | +# if sed.get("ForwardAgent",False): |
3566 | +# ForwardAgent = doc2.createElement("ForwardAgent") |
3567 | +# Contacts.appendChild(ForwardAgent) |
3568 | +# |
3569 | +# CompanyName = doc2.createElement("CompanyName") |
3570 | +# ptext = doc1.createTextNode(sed['Contacts']['ForwardAgent']['CompanyName']) |
3571 | +# CompanyName.appendChild(ptext) |
3572 | +# ForwardAgent.appendChild(CompanyName) |
3573 | +# |
3574 | +# TaxIdentificationNumber = doc2.createElement("TaxIdentificationNumber") |
3575 | +# ptext = doc1.createTextNode(sed['Contacts']['ForwardAgent']["TaxIdentificationNumber"]) |
3576 | +# TaxIdentificationNumber.appendChild(ptext) |
3577 | +# ForwardAgent.appendChild(TaxIdentificationNumber) |
3578 | +# |
3579 | +# Address = doc2.createElement("Address") |
3580 | +# ForwardAgent.appendChild(Address) |
3581 | +# |
3582 | +# AddressLine1 = doc2.createElement("AddressLine1") |
3583 | +# ptext = doc1.createTextNode(sed['Contacts']['ForwardAgent']['Address']['AddressLine1']) |
3584 | +# AddressLine1.appendChild(ptext) |
3585 | +# Address.appendChild(AddressLine1) |
3586 | +# |
3587 | +# AddressLine2 = doc2.createElement("AddressLine2") |
3588 | +# ptext = doc1.createTextNode(sed['Contacts']['ForwardAgent']['Address']['AddressLine2']) |
3589 | +# AddressLine2.appendChild(ptext) |
3590 | +# Address.appendChild(AddressLine2) |
3591 | +# |
3592 | +# City = doc2.createElement("City") |
3593 | +# ptext = doc1.createTextNode(sed['Contacts']['ForwardAgent']['Address']['City']) |
3594 | +# City.appendChild(ptext) |
3595 | +# Address.appendChild(City) |
3596 | +# |
3597 | +# StateProvinceCode = doc2.createElement("StateProvinceCode") |
3598 | +# ptext = doc1.createTextNode(sed['Contacts']['ForwardAgent']['Address']['StateProvinceCode']) |
3599 | +# StateProvinceCode.appendChild(ptext) |
3600 | +# Address.appendChild(StateProvinceCode) |
3601 | +# |
3602 | +# PostalCode = doc2.createElement("PostalCode") |
3603 | +# ptext = doc1.createTextNode(sed['Contacts']['ForwardAgent']['Address']['PostalCode']) |
3604 | +# PostalCode.appendChild(ptext) |
3605 | +# Address.appendChild(PostalCode) |
3606 | +# |
3607 | +# CountryCode = doc2.createElement("CountryCode") |
3608 | +# ptext = doc1.createTextNode(sed['Contacts']['ForwardAgent']['Address']['CountryCode']) |
3609 | +# CountryCode.appendChild(ptext) |
3610 | +# Address.appendChild(CountryCode) |
3611 | +# if sed.get("UltimateConsignee",False): |
3612 | +# |
3613 | +# UltimateConsignee = doc2.createElement("UltimateConsignee") |
3614 | +# Contacts.appendChild(UltimateConsignee) |
3615 | +# |
3616 | +# CompanyName = doc2.createElement("CompanyName") |
3617 | +# ptext = doc1.createTextNode(sed["Contacts"]['UltimateConsignee']['CompanyName']) |
3618 | +# CompanyName.appendChild(ptext) |
3619 | +# UltimateConsignee.appendChild(CompanyName) |
3620 | +# |
3621 | +# Address = doc2.createElement("Address") |
3622 | +# UltimateConsignee.appendChild(Address) |
3623 | +# |
3624 | +# AddressLine1 = doc2.createElement("AddressLine1") |
3625 | +# ptext = doc1.createTextNode(sed["Contacts"]['UltimateConsignee']['Address']['AddressLine1']) |
3626 | +# AddressLine1.appendChild(ptext) |
3627 | +# Address.appendChild(AddressLine1) |
3628 | +# |
3629 | +# AddressLine2 = doc2.createElement("AddressLine2") |
3630 | +# ptext = doc1.createTextNode(sed["Contacts"]['UltimateConsignee']['Address']['AddressLine2']) |
3631 | +# AddressLine2.appendChild(ptext) |
3632 | +# Address.appendChild(AddressLine2) |
3633 | +# |
3634 | +# City = doc2.createElement("City") |
3635 | +# ptext = doc1.createTextNode(sed["Contacts"]['UltimateConsignee']['Address']['City']) |
3636 | +# City.appendChild(ptext) |
3637 | +# Address.appendChild(City) |
3638 | +# |
3639 | +# StateProvinceCode = doc2.createElement("StateProvinceCode") |
3640 | +# ptext = doc1.createTextNode(sed["Contacts"]['UltimateConsignee']['Address']['StateProvinceCode']) |
3641 | +# StateProvinceCode.appendChild(ptext) |
3642 | +# Address.appendChild(StateProvinceCode) |
3643 | +# |
3644 | +# PostalCode = doc2.createElement("PostalCode") |
3645 | +# ptext = doc1.createTextNode(sed["Contacts"]['UltimateConsignee']['Address']['PostalCode']) |
3646 | +# PostalCode.appendChild(ptext) |
3647 | +# Address.appendChild(PostalCode) |
3648 | +# |
3649 | +# CountryCode = doc2.createElement("CountryCode") |
3650 | +# ptext = doc1.createTextNode(sed["Contacts"]['UltimateConsignee']['Address']['CountryCode']) |
3651 | +# CountryCode.appendChild(ptext) |
3652 | +# Address.appendChild(CountryCode) |
3653 | +# |
3654 | +# if sed.get("IntermediateConsignee",False): |
3655 | +# IntermediateConsignee = doc2.createElement("IntermediateConsignee") |
3656 | +# Contacts.appendChild(IntermediateConsignee) |
3657 | +# |
3658 | +# |
3659 | +# |
3660 | +# CompanyName = doc2.createElement("CompanyName") |
3661 | +# ptext = doc1.createTextNode(sed["Contacts"]['IntermediateConsignee']['CompanyName']) |
3662 | +# CompanyName.appendChild(ptext) |
3663 | +# IntermediateConsignee.appendChild(CompanyName) |
3664 | +# |
3665 | +# |
3666 | +# |
3667 | +# Address = doc2.createElement("Address") |
3668 | +# IntermediateConsignee.appendChild(Address) |
3669 | +# |
3670 | +# AddressLine1 = doc2.createElement("AddressLine1") |
3671 | +# ptext = doc1.createTextNode(sed["Contacts"]['IntermediateConsignee']['Address']['AddressLine1']) |
3672 | +# AddressLine1.appendChild(ptext) |
3673 | +# Address.appendChild(AddressLine1) |
3674 | +# |
3675 | +# AddressLine2 = doc2.createElement("AddressLine2") |
3676 | +# ptext = doc1.createTextNode(sed["Contacts"]['IntermediateConsignee']['Address']['AddressLine2']) |
3677 | +# AddressLine2.appendChild(ptext) |
3678 | +# Address.appendChild(AddressLine2) |
3679 | +# |
3680 | +# City = doc2.createElement("City") |
3681 | +# ptext = doc1.createTextNode(sed["Contacts"]['IntermediateConsignee']['Address']['City']) |
3682 | +# City.appendChild(ptext) |
3683 | +# Address.appendChild(City) |
3684 | +# |
3685 | +# StateProvinceCode = doc2.createElement("StateProvinceCode") |
3686 | +# ptext = doc1.createTextNode(sed["Contacts"]['IntermediateConsignee']['Address']['StateProvinceCode']) |
3687 | +# StateProvinceCode.appendChild(ptext) |
3688 | +# Address.appendChild(StateProvinceCode) |
3689 | +# |
3690 | +# PostalCode = doc2.createElement("PostalCode") |
3691 | +# ptext = doc1.createTextNode(sed["Contacts"]['IntermediateConsignee']['Address']['PostalCode']) |
3692 | +# PostalCode.appendChild(ptext) |
3693 | +# Address.appendChild(PostalCode) |
3694 | +# |
3695 | +# CountryCode = doc2.createElement("CountryCode") |
3696 | +# ptext = doc1.createTextNode(sed["Contacts"]['IntermediateConsignee']['Address']['CountryCode']) |
3697 | +# CountryCode.appendChild(ptext) |
3698 | +# Address.appendChild(CountryCode) |
3699 | + if nafta_cer_orig and nafta_cer_orig["Contacts"].get("Producer"): |
3700 | + Producer = doc2.createElement("Producer") |
3701 | + Contacts.appendChild(Producer) |
3702 | + if nafta_cer_orig["Contacts"]['Producer'].get('Option') != ' ': |
3703 | + Option = doc2.createElement("Option") |
3704 | + ptext = doc1.createTextNode(nafta_cer_orig["Contacts"]['Producer']['Option']) |
3705 | + Option.appendChild(ptext) |
3706 | + Producer.appendChild(Option) |
3707 | + else: |
3708 | + CompanyName = doc2.createElement("CompanyName") |
3709 | + ptext = doc1.createTextNode(nafta_cer_orig["Contacts"]['Producer']['CompanyName']) |
3710 | + CompanyName.appendChild(ptext) |
3711 | + Producer.appendChild(CompanyName) |
3712 | + |
3713 | + TaxIdentificationNumber = doc2.createElement("TaxIdentificationNumber") |
3714 | + ptext = doc1.createTextNode(nafta_cer_orig["Contacts"]['Producer']['TaxIdentificationNumber']) |
3715 | + TaxIdentificationNumber.appendChild(ptext) |
3716 | + Producer.appendChild(TaxIdentificationNumber) |
3717 | + |
3718 | + Address = doc2.createElement("Address") |
3719 | + Producer.appendChild(Address) |
3720 | + |
3721 | + AddressLine1 = doc2.createElement("AddressLine1") |
3722 | + ptext = doc1.createTextNode(nafta_cer_orig["Contacts"]['Producer']['Address']['AddressLine1']) |
3723 | + AddressLine1.appendChild(ptext) |
3724 | + Address.appendChild(AddressLine1) |
3725 | + |
3726 | + AddressLine2 = doc2.createElement("AddressLine2") |
3727 | + ptext = doc1.createTextNode(nafta_cer_orig["Contacts"]['Producer']['Address']['AddressLine2']) |
3728 | + AddressLine2.appendChild(ptext) |
3729 | + Address.appendChild(AddressLine2) |
3730 | + |
3731 | + City = doc2.createElement("City") |
3732 | + ptext = doc1.createTextNode(nafta_cer_orig["Contacts"]['Producer']['Address']['City']) |
3733 | + City.appendChild(ptext) |
3734 | + Address.appendChild(City) |
3735 | + |
3736 | + StateProvinceCode = doc2.createElement("StateProvinceCode") |
3737 | + ptext = doc1.createTextNode(nafta_cer_orig["Contacts"]['Producer']['Address']['StateProvinceCode']) |
3738 | + StateProvinceCode.appendChild(ptext) |
3739 | + Address.appendChild(StateProvinceCode) |
3740 | + |
3741 | + PostalCode = doc2.createElement("PostalCode") |
3742 | + ptext = doc1.createTextNode(nafta_cer_orig["Contacts"]['Producer']['Address']['PostalCode']) |
3743 | + PostalCode.appendChild(ptext) |
3744 | + Address.appendChild(PostalCode) |
3745 | + |
3746 | + CountryCode = doc2.createElement("CountryCode") |
3747 | + ptext = doc1.createTextNode(nafta_cer_orig["Contacts"]['Producer']['Address']['CountryCode']) |
3748 | + CountryCode.appendChild(ptext) |
3749 | + Address.appendChild(CountryCode) |
3750 | + |
3751 | + Product_count = len(prod) > 50 and 50 or len(prod) |
3752 | + if comm_inv or cer_orig or nafta_cer_orig or sed: |
3753 | + for i in range (0,Product_count): |
3754 | + #/////////// |
3755 | + #########code for product dictionary |
3756 | + #/////////// |
3757 | + |
3758 | + Product = doc2.createElement("Product") |
3759 | + InternationalForms.appendChild(Product) |
3760 | + |
3761 | + Description = doc2.createElement("Description") |
3762 | + ptext = doc1.createTextNode(prod[i]['Description']) |
3763 | + Description.appendChild(ptext) |
3764 | + Product.appendChild(Description) |
3765 | + if comm_inv: |
3766 | + Unit = doc2.createElement("Unit") |
3767 | + Product.appendChild(Unit) |
3768 | + Number = doc2.createElement("Number") |
3769 | + ptext = doc1.createTextNode(prod[i]['Unit']['Number']) |
3770 | + Number.appendChild(ptext) |
3771 | + Unit.appendChild(Number) |
3772 | + |
3773 | + Value = doc2.createElement("Value") |
3774 | + ptext = doc1.createTextNode(prod[i]['Unit']['Value']) |
3775 | + Value.appendChild(ptext) |
3776 | + Unit.appendChild(Value) |
3777 | + |
3778 | + UnitOfMeasurement = doc2.createElement("UnitOfMeasurement") |
3779 | + Unit.appendChild(UnitOfMeasurement) |
3780 | + Code = doc2.createElement("Code") |
3781 | + ptext = doc1.createTextNode(prod[i]['Unit']['UnitOfMeasurement']['Code']) |
3782 | + Code.appendChild(ptext) |
3783 | + UnitOfMeasurement.appendChild(Code) |
3784 | + |
3785 | + Description = doc2.createElement("Description") |
3786 | + ptext = doc1.createTextNode(prod[i]['Unit']['UnitOfMeasurement']['Description']) |
3787 | + Description.appendChild(ptext) |
3788 | + UnitOfMeasurement.appendChild(Description) |
3789 | + if nafta_cer_orig or comm_inv: |
3790 | + CommodityCode = doc2.createElement("CommodityCode") |
3791 | + ptext = doc1.createTextNode(prod[i]['CommodityCode']) |
3792 | + CommodityCode.appendChild(ptext) |
3793 | + Product.appendChild(CommodityCode) |
3794 | +# if comm_inv: |
3795 | +# PartNumber = doc2.createElement("PartNumber") |
3796 | +# ptext = doc1.createTextNode(prod[i]['PartNumber']) |
3797 | +# CommodityCode.appendChild(ptext) |
3798 | +# Product.appendChild(PartNumber) |
3799 | + if nafta_cer_orig or comm_inv or cer_orig: |
3800 | + OriginCountryCode = doc2.createElement("OriginCountryCode") |
3801 | + ptext = doc1.createTextNode(prod[i]['OriginCountryCode']) |
3802 | + OriginCountryCode.appendChild(ptext) |
3803 | + Product.appendChild(OriginCountryCode) |
3804 | + if nafta_cer_orig: |
3805 | +# JointProductionIndicator = doc2.createElement("JointProductionIndicator") |
3806 | +# ptext = doc1.createTextNode(prod[i]['JointProductionIndicator']) |
3807 | +# JointProductionIndicator.appendChild(ptext) |
3808 | +# Product.appendChild(JointProductionIndicator) |
3809 | + |
3810 | + NetCostCode = doc2.createElement("NetCostCode") |
3811 | + ptext = doc1.createTextNode(prod[i]['NetCostCode']) |
3812 | + NetCostCode.appendChild(ptext) |
3813 | + Product.appendChild(NetCostCode) |
3814 | + |
3815 | +# NetCostDateRange = doc2.createElement("NetCostDateRange") |
3816 | +# Product.appendChild(NetCostDateRange) |
3817 | +# BeginDate = doc2.createElement("BeginDate") |
3818 | +# ptext = doc1.createTextNode(prod[i]['NetCostDateRange']['BeginDate']) |
3819 | +# BeginDate.appendChild(ptext) |
3820 | +# NetCostDateRange.appendChild(BeginDate) |
3821 | +# |
3822 | +# EndDate = doc2.createElement("EndDate") |
3823 | +# ptext = doc1.createTextNode(prod[i]['NetCostDateRange']['EndDate']) |
3824 | +# EndDate.appendChild(ptext) |
3825 | +# NetCostDateRange.appendChild(EndDate) |
3826 | + |
3827 | + PreferenceCriteria = doc2.createElement("PreferenceCriteria") |
3828 | + ptext = doc1.createTextNode(prod[i]['PreferenceCriteria']) |
3829 | + PreferenceCriteria.appendChild(ptext) |
3830 | + Product.appendChild(PreferenceCriteria) |
3831 | + |
3832 | + |
3833 | + ProducerInfo = doc2.createElement("ProducerInfo") |
3834 | + ptext = doc1.createTextNode(prod[i]['ProducerInfo']) |
3835 | + ProducerInfo.appendChild(ptext) |
3836 | + Product.appendChild(ProducerInfo) |
3837 | + if cer_orig: |
3838 | +# MarksAndNumbers = doc2.createElement("MarksAndNumbers") |
3839 | +# ptext = doc1.createTextNode(prod[i]['MarksAndNumbers']) |
3840 | +# MarksAndNumbers.appendChild(ptext) |
3841 | +# Product.appendChild(MarksAndNumbers) |
3842 | + |
3843 | + NumberOfPackagesPerCommodity = doc2.createElement("NumberOfPackagesPerCommodity") |
3844 | + ptext = doc1.createTextNode(prod[i]['NumberOfPackagesPerCommodity']) |
3845 | + NumberOfPackagesPerCommodity.appendChild(ptext) |
3846 | + Product.appendChild(NumberOfPackagesPerCommodity) |
3847 | + |
3848 | + |
3849 | + ProductWeight = doc2.createElement("ProductWeight") |
3850 | + Product.appendChild(ProductWeight) |
3851 | + UnitOfMeasurement = doc2.createElement("UnitOfMeasurement") |
3852 | + ProductWeight.appendChild(UnitOfMeasurement) |
3853 | + Code = doc2.createElement("Code") |
3854 | + ptext = doc1.createTextNode(prod[i]['ProductWeight']['UnitOfMeasurement']['Code']) |
3855 | + Code.appendChild(ptext) |
3856 | + UnitOfMeasurement.appendChild(Code) |
3857 | + |
3858 | + Description = doc2.createElement("Description") |
3859 | + ptext = doc1.createTextNode(prod[i]['ProductWeight']['UnitOfMeasurement']['Description']) |
3860 | + Description.appendChild(ptext) |
3861 | + UnitOfMeasurement.appendChild(Description) |
3862 | + |
3863 | + Weight = doc2.createElement("Weight") |
3864 | + ptext = doc1.createTextNode(prod[i]['ProductWeight']['Weight']) |
3865 | + Weight.appendChild(ptext) |
3866 | + ProductWeight.appendChild(Weight) |
3867 | +# if sed: |
3868 | +# VehicleID = doc2.createElement("VehicleID") |
3869 | +# ptext = doc1.createTextNode(prod[i]['VehicleID']) |
3870 | +# VehicleID.appendChild(ptext) |
3871 | +# Product.appendChild(VehicleID) |
3872 | +# |
3873 | +# ScheduleB = doc2.createElement("ScheduleB") |
3874 | +# Product.appendChild(ScheduleB) |
3875 | +# Number = doc2.createElement("Number") |
3876 | +# ptext = doc1.createTextNode(prod[i]['ScheduleB']['Number']) |
3877 | +# Number.appendChild(ptext) |
3878 | +# ScheduleB.appendChild(Number) |
3879 | +# |
3880 | +# Quantity = doc2.createElement("Quantity") |
3881 | +# ptext = doc1.createTextNode(prod[i]['ScheduleB']['Quantity']) |
3882 | +# Quantity.appendChild(ptext) |
3883 | +# ScheduleB.appendChild(Quantity) |
3884 | +# |
3885 | +# UnitOfMeasurement = doc2.createElement("UnitOfMeasurement") |
3886 | +# ScheduleB.appendChild(UnitOfMeasurement) |
3887 | +# Code = doc2.createElement("Code") |
3888 | +# ptext = doc1.createTextNode(prod[i]['ScheduleB']['UnitOfMeasurement']['Code']) |
3889 | +# Code.appendChild(ptext) |
3890 | +# UnitOfMeasurement.appendChild(Code) |
3891 | +# |
3892 | +# Description = doc2.createElement("Description") |
3893 | +# ptext = doc1.createTextNode(prod[i]['ScheduleB']['UnitOfMeasurement']['Description']) |
3894 | +# Description.appendChild(ptext) |
3895 | +# UnitOfMeasurement.appendChild(Description) |
3896 | +# |
3897 | +# ExportType = doc2.createElement("ExportType") |
3898 | +# ptext = doc1.createTextNode(prod[i]['ExportType']) |
3899 | +# Description.appendChild(ptext) |
3900 | +# Product.appendChild(ExportType) |
3901 | +# |
3902 | +# SEDTotalValue = doc2.createElement("SEDTotalValue") |
3903 | +# ptext = doc1.createTextNode(prod[i]['SEDTotalValue']) |
3904 | +# SEDTotalValue.appendChild(ptext) |
3905 | +# Product.appendChild(SEDTotalValue) |
3906 | +# |
3907 | + |
3908 | + #/////////end loop in code |
3909 | + |
3910 | + |
3911 | + if comm_inv: |
3912 | +# InvoiceNumber = doc2.createElement("InvoiceNumber") |
3913 | +# ptext = doc1.createTextNode(comm_inv["InvoiceNumber"]) |
3914 | +# InvoiceNumber.appendChild(ptext) |
3915 | +# InternationalForms.appendChild(InvoiceNumber) |
3916 | + if comm_inv.get("InvoiceDate"): |
3917 | + InvoiceDate = doc2.createElement("InvoiceDate") |
3918 | + ptext = doc1.createTextNode(comm_inv["InvoiceDate"]) |
3919 | + InvoiceDate.appendChild(ptext) |
3920 | + InternationalForms.appendChild(InvoiceDate) |
3921 | + |
3922 | +# PurchaseOrderNumber = doc2.createElement("PurchaseOrderNumber") |
3923 | +# ptext = doc1.createTextNode(comm_inv["PurchaseOrderNumber"]) |
3924 | +# InvoiceNumber.appendChild(ptext) |
3925 | +# InternationalForms.appendChild(PurchaseOrderNumber) |
3926 | +# |
3927 | +# TermsOfShipment = doc2.createElement("TermsOfShipment") |
3928 | +# ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["ShipmentServiceOptions"]["InternationalForms"]["TermsOfShipment"]) |
3929 | +# TermsOfShipment.appendChild(ptext) |
3930 | +# InternationalForms.appendChild(TermsOfShipment) |
3931 | + |
3932 | + ReasonForExport = doc2.createElement("ReasonForExport") |
3933 | + ptext = doc1.createTextNode(comm_inv["ReasonForExport"]) |
3934 | + ReasonForExport.appendChild(ptext) |
3935 | + InternationalForms.appendChild(ReasonForExport) |
3936 | + |
3937 | +# Comments = doc2.createElement("Comments") |
3938 | +# ptext = doc1.createTextNode(comm_inv["Comments"]) |
3939 | +# Comments.appendChild(ptext) |
3940 | +# InternationalForms.appendChild(Comments) |
3941 | + |
3942 | + DeclarationStatement = doc2.createElement("DeclarationStatement") |
3943 | + ptext = doc1.createTextNode(comm_inv["DeclarationStatement"]) |
3944 | + DeclarationStatement.appendChild(ptext) |
3945 | + InternationalForms.appendChild(DeclarationStatement) |
3946 | + |
3947 | +# Discount = doc2.createElement("Discount") |
3948 | +# InternationalForms.appendChild(Discount) |
3949 | +# |
3950 | +# MonetaryValue = doc2.createElement("MonetaryValue") |
3951 | +# ptext = doc1.createTextNode(comm_inv['Discount']["MonetaryValue"]) |
3952 | +# MonetaryValue.appendChild(ptext) |
3953 | +# Discount.appendChild(MonetaryValue) |
3954 | +# |
3955 | +# FreightCharges = doc2.createElement("FreightCharges") |
3956 | +# InternationalForms.appendChild(FreightCharges) |
3957 | +# MonetaryValue = doc2.createElement("MonetaryValue") |
3958 | +# ptext = doc1.createTextNode(comm_inv['FreightCharges']["MonetaryValue"]) |
3959 | +# MonetaryValue.appendChild(ptext) |
3960 | +# FreightCharges.appendChild(MonetaryValue) |
3961 | +# |
3962 | +# InsuranceCharges = doc2.createElement("InsuranceCharges") |
3963 | +# InternationalForms.appendChild(InsuranceCharges) |
3964 | +# MonetaryValue = doc2.createElement("MonetaryValue") |
3965 | +# ptext = doc1.createTextNode(comm_inv['InsuranceCharges']["MonetaryValue"]) |
3966 | +# MonetaryValue.appendChild(ptext) |
3967 | +# InsuranceCharges.appendChild(MonetaryValue) |
3968 | +# |
3969 | +# OtherCharges = doc2.createElement("OtherCharges") |
3970 | +# InternationalForms.appendChild(OtherCharges) |
3971 | +# MonetaryValue = doc2.createElement("MonetaryValue") |
3972 | +# ptext = doc1.createTextNode(comm_inv['OtherCharges']["MonetaryValue"]) |
3973 | +# MonetaryValue.appendChild(ptext) |
3974 | +# OtherCharges.appendChild(MonetaryValue) |
3975 | +# |
3976 | +# Description = doc2.createElement("Description") |
3977 | +# ptext = doc1.createTextNode(comm_inv['OtherCharges']["Description"]) |
3978 | +# Description.appendChild(ptext) |
3979 | +# OtherCharges.appendChild(Description) |
3980 | + |
3981 | + CurrencyCode = doc2.createElement("CurrencyCode") |
3982 | + ptext = doc1.createTextNode(comm_inv["CurrencyCode"]) |
3983 | + CurrencyCode.appendChild(ptext) |
3984 | + InternationalForms.appendChild(CurrencyCode) |
3985 | + if nafta_cer_orig and nafta_cer_orig.get('BlanketPeriod'): |
3986 | + BlanketPeriod = doc2.createElement("BlanketPeriod") |
3987 | + InternationalForms.appendChild(BlanketPeriod) |
3988 | + |
3989 | + BeginDate = doc2.createElement("BeginDate") |
3990 | + ptext = doc1.createTextNode(nafta_cer_orig['BlanketPeriod']["BeginDate"]) |
3991 | + BeginDate.appendChild(ptext) |
3992 | + BlanketPeriod.appendChild(BeginDate) |
3993 | + |
3994 | + EndDate = doc2.createElement("EndDate") |
3995 | + ptext = doc1.createTextNode(nafta_cer_orig['BlanketPeriod']["EndDate"]) |
3996 | + EndDate.appendChild(ptext) |
3997 | + BlanketPeriod.appendChild(EndDate) |
3998 | + if cer_orig or sed: |
3999 | + ExportDate = doc2.createElement("ExportDate") |
4000 | + ptext = doc1.createTextNode(cer_orig['ExportDate']) |
4001 | + ExportDate.appendChild(ptext) |
4002 | + InternationalForms.appendChild(ExportDate) |
4003 | + |
4004 | + ExportingCarrier = doc2.createElement("ExportingCarrier") |
4005 | + ptext = doc1.createTextNode(cer_orig['ExportingCarrier']) |
4006 | + ExportingCarrier.appendChild(ptext) |
4007 | + InternationalForms.appendChild(ExportingCarrier) |
4008 | +# if sed: |
4009 | +# if sed['CarrierID']: |
4010 | +# CarrierID = doc2.createElement("CarrierID") |
4011 | +# ptext = doc1.createTextNode(sed['CarrierID']) |
4012 | +# CarrierID.appendChild(ptext) |
4013 | +# InternationalForms.appendChild(CarrierID) |
4014 | +# |
4015 | +# InBondCode = doc2.createElement("InBondCode") |
4016 | +# ptext = doc1.createTextNode(sed['InBondCode']) |
4017 | +# InBondCode.appendChild(ptext) |
4018 | +# InternationalForms.appendChild(InBondCode) |
4019 | +# if sed['InBondCode'] != '70': |
4020 | +# EntryNumber = doc2.createElement("EntryNumber") |
4021 | +# ptext = doc1.createTextNode(sed['EntryNumber']) |
4022 | +# EntryNumber.appendChild(ptext) |
4023 | +# InternationalForms.appendChild(EntryNumber) |
4024 | +# |
4025 | +# PointOfOrigin = doc2.createElement("PointOfOrigin") |
4026 | +# ptext = doc1.createTextNode(sed['PointOfOrigin']) |
4027 | +# PointOfOrigin.appendChild(ptext) |
4028 | +# InternationalForms.appendChild(PointOfOrigin) |
4029 | +# |
4030 | +# ModeOfTransport = doc2.createElement("ModeOfTransport") |
4031 | +# ptext = doc1.createTextNode(sed['ModeOfTransport']) |
4032 | +# ModeOfTransport.appendChild(ptext) |
4033 | +# InternationalForms.appendChild(ModeOfTransport) |
4034 | +# if sed['PortOfExport']: |
4035 | +# PortOfExport = doc2.createElement("PortOfExport") |
4036 | +# ptext = doc1.createTextNode(sed['PortOfExport']) |
4037 | +# PortOfExport.appendChild(ptext) |
4038 | +# InternationalForms.appendChild(PortOfExport) |
4039 | +# if sed['PortOfUnloading']: |
4040 | +# PortOfUnloading = doc2.createElement("PortOfUnloading") |
4041 | +# ptext = doc1.createTextNode(sed['PortOfUnloading']) |
4042 | +# PortOfUnloading.appendChild(ptext) |
4043 | +# InternationalForms.appendChild(PortOfUnloading) |
4044 | +# if sed['LoadingPier']: |
4045 | +# LoadingPier = doc2.createElement("LoadingPier") |
4046 | +# ptext = doc1.createTextNode(sed['LoadingPier']) |
4047 | +# LoadingPier.appendChild(ptext) |
4048 | +# InternationalForms.appendChild(LoadingPier) |
4049 | +# if sed['PartiesToTransaction']: |
4050 | +# PartiesToTransaction = doc2.createElement("PartiesToTransaction") |
4051 | +# ptext = doc1.createTextNode(sed['PartiesToTransaction']) |
4052 | +# PartiesToTransaction.appendChild(ptext) |
4053 | +# InternationalForms.appendChild(PartiesToTransaction) |
4054 | +# |
4055 | +# if sed['RoutedExportTransactionIndicator']: |
4056 | +# RoutedExportTransactionIndicator = doc2.createElement("RoutedExportTransactionIndicator") |
4057 | +# InternationalForms.appendChild(RoutedExportTransactionIndicator) |
4058 | +# |
4059 | +# if sed['ContainerizedIndicator']: |
4060 | +# ContainerizedIndicator = doc2.createElement("ContainerizedIndicator") |
4061 | +# InternationalForms.appendChild(ContainerizedIndicator) |
4062 | +# |
4063 | +# License = doc2.createElement("License") |
4064 | +# InternationalForms.appendChild(License) |
4065 | +# if sed['License'].get('Number'): |
4066 | +# Number = doc2.createElement("Number") |
4067 | +# ptext = doc1.createTextNode(sed['License']['Number']) |
4068 | +# Number.appendChild(ptext) |
4069 | +# License.appendChild(Number) |
4070 | +# |
4071 | +# Date = doc2.createElement("Date") |
4072 | +# ptext = doc1.createTextNode(sed['License']['Date']) |
4073 | +# Date.appendChild(ptext) |
4074 | +# InternationalForms.appendChild(Date) |
4075 | +# |
4076 | +# elif sed['License'].get('ExceptionCode'): |
4077 | +# ExceptionCode = doc2.createElement("ExceptionCode") |
4078 | +# ptext = doc1.createTextNode(sed['License']['ExceptionCode']) |
4079 | +# ExceptionCode.appendChild(ptext) |
4080 | +# License.appendChild(ExceptionCode) |
4081 | +# if sed['License']['ExceptionCode'] in ('CIV','CTP','ENC','KMI','LVS'): |
4082 | +# ECCNNumber = doc2.createElement("ECCNNumber") |
4083 | +# ptext = doc1.createTextNode(sed['ECCNNumber']) |
4084 | +# ECCNNumber.appendChild(ptext) |
4085 | +# InternationalForms.appendChild(ECCNNumber) |
4086 | + |
4087 | + # ReturnOfDocumentIndicator = doc2.createElement("ReturnOfDocumentIndicator") |
4088 | + # ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["ShipmentServiceOptions"]["ReturnOfDocumentIndicator"]) |
4089 | + # ReturnOfDocumentIndicator.appendChild(ptext) |
4090 | + # ShipmentServiceOptions.appendChild(ReturnOfDocumentIndicator) |
4091 | + # |
4092 | + # ImportControlIndicator = doc2.createElement("ImportControlIndicator") |
4093 | + # ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["ShipmentServiceOptions"]["ImportControlIndicator"]) |
4094 | + # ImportControlIndicator.appendChild(ptext) |
4095 | + # ShipmentServiceOptions.appendChild(ImportControlIndicator) |
4096 | + # |
4097 | + # LabelMethod = doc2.createElement("LabelMethod") |
4098 | + # ShipmentServiceOptions.appendChild(LabelMethod) |
4099 | + # Code = doc2.createElement("Code") |
4100 | + # ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["ShipmentServiceOptions"]["LabelMethod"]["Code"]) |
4101 | + # Code.appendChild(ptext) |
4102 | + # LabelMethod.appendChild(Code) |
4103 | + # |
4104 | + # Description = doc2.createElement("Description") |
4105 | + # ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["ShipmentServiceOptions"]["LabelMethod"]["Description"]) |
4106 | + # Description.appendChild(ptext) |
4107 | + # LabelMethod.appendChild(Description) |
4108 | + |
4109 | + # CommercialInvoiceRemovalIndicator = doc2.createElement("CommercialInvoiceRemovalIndicator") |
4110 | + # ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["ShipmentServiceOptions"]["CommercialInvoiceRemovalIndicator"]) |
4111 | + # CommercialInvoiceRemovalIndicator.appendChild(ptext) |
4112 | + # ShipmentServiceOptions.appendChild(CommercialInvoiceRemovalIndicator) |
4113 | + |
4114 | + # UPScarbonneutralIndicator = doc2.createElement("UPScarbonneutralIndicator") |
4115 | + # ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["ShipmentServiceOptions"]["UPScarbonneutralIndicator"]) |
4116 | + # UPScarbonneutralIndicator.appendChild(ptext) |
4117 | + # ShipmentServiceOptions.appendChild(UPScarbonneutralIndicator) |
4118 | + |
4119 | + # DeliveryConfirmation = doc2.createElement("DeliveryConfirmation") |
4120 | + # ShipmentServiceOptions.appendChild(DeliveryConfirmation) |
4121 | + # DCISType = doc2.createElement("DCISType") |
4122 | + # ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["ShipmentServiceOptions"]["DeliveryConfirmation"]["DCISType"]) |
4123 | + # DCISType.appendChild(ptext) |
4124 | + # DeliveryConfirmation.appendChild(DCISType) |
4125 | + |
4126 | + Package_count = len(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["Package"]) |
4127 | + for i in range(0,Package_count): |
4128 | + Package = doc2.createElement("Package") |
4129 | + Shipment.appendChild(Package) |
4130 | + |
4131 | + Description = doc2.createElement("Description") |
4132 | + ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["Package"][i]["Description"]) |
4133 | + Description.appendChild(ptext) |
4134 | + Package.appendChild(Description) |
4135 | + PackagingType = doc2.createElement("PackagingType") |
4136 | + Package.appendChild(PackagingType) |
4137 | + |
4138 | + Code = doc2.createElement("Code") |
4139 | + ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["Package"][i]["PackagingType"]['Code']) |
4140 | + Code.appendChild(ptext) |
4141 | + PackagingType.appendChild(Code) |
4142 | + Description = doc2.createElement("Description") |
4143 | + ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["Package"][i]["PackagingType"]['Description']) |
4144 | + Description.appendChild(ptext) |
4145 | + PackagingType.appendChild(Description) |
4146 | + |
4147 | + Dimensions = doc2.createElement("Dimensions") |
4148 | + Package.appendChild(Dimensions) |
4149 | + |
4150 | + Length = doc2.createElement("Length") |
4151 | + ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["Package"][i]["Dimensions"]["Length"]) |
4152 | + Length.appendChild(ptext) |
4153 | + Dimensions.appendChild(Length) |
4154 | + Width = doc2.createElement("Width") |
4155 | + ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["Package"][i]["Dimensions"]["Width"]) |
4156 | + Width.appendChild(ptext) |
4157 | + Dimensions.appendChild(Width) |
4158 | + Height = doc2.createElement("Height") |
4159 | + ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["Package"][i]["Dimensions"]["Height"]) |
4160 | + Height.appendChild(ptext) |
4161 | + Dimensions.appendChild(Height) |
4162 | + UnitOfMeasurement = doc2.createElement("UnitOfMeasurement") |
4163 | + Dimensions.appendChild(UnitOfMeasurement) |
4164 | + |
4165 | + Code = doc2.createElement("Code") |
4166 | + ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["Package"][i]["Dimensions"]['UnitOfMeasurement']["Code"]) |
4167 | + Code.appendChild(ptext) |
4168 | + UnitOfMeasurement.appendChild(Code) |
4169 | + Description = doc2.createElement("Description") |
4170 | + ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["Package"][i]["Dimensions"]['UnitOfMeasurement']["Description"]) |
4171 | + Description.appendChild(ptext) |
4172 | + UnitOfMeasurement.appendChild(Description) |
4173 | + |
4174 | + |
4175 | + PackageWeight = doc2.createElement("PackageWeight") |
4176 | + Package.appendChild(PackageWeight) |
4177 | + |
4178 | + UnitOfMeasurement = doc2.createElement("UnitOfMeasurement") |
4179 | + PackageWeight.appendChild(UnitOfMeasurement) |
4180 | + Code = doc2.createElement("Code") |
4181 | + ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["Package"][i]['PackageWeight']['UnitOfMeasurement']["Code"]) |
4182 | + Code.appendChild(ptext) |
4183 | + UnitOfMeasurement.appendChild(Code) |
4184 | + |
4185 | + Description = doc2.createElement("Description") |
4186 | + ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["Package"][i]['PackageWeight']['UnitOfMeasurement']["Description"]) |
4187 | + Description.appendChild(ptext) |
4188 | + UnitOfMeasurement.appendChild(Description) |
4189 | + |
4190 | + Weight = doc2.createElement("Weight") |
4191 | + ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["Package"][i]['PackageWeight']["Weight"]) |
4192 | + Weight.appendChild(ptext) |
4193 | + PackageWeight.appendChild(Weight) |
4194 | + # LargePackageIndicator = doc2.createElement("LargePackageIndicator") |
4195 | + ## ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["Package"][i]["LargePackageIndicator"]) |
4196 | + ## LargePackageIndicator.appendChild(ptext) |
4197 | + # Package.appendChild(LargePackageIndicator) |
4198 | + |
4199 | +# ReferenceNumber = doc2.createElement("ReferenceNumber") |
4200 | +# Package.appendChild(ReferenceNumber) |
4201 | +# |
4202 | +# BarCodeIndicator = doc2.createElement("BarCodeIndicator") |
4203 | +# # ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["Package"][i]["ReferenceNumber"]["BarCodeIndicator"]) |
4204 | +# # BarCodeIndicator.appendChild(ptext) |
4205 | +# ReferenceNumber.appendChild(BarCodeIndicator) |
4206 | +# |
4207 | +# Code = doc2.createElement("Code") |
4208 | +# ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["Package"][i]["ReferenceNumber"]["Code"]) |
4209 | +# Code.appendChild(ptext) |
4210 | +# ReferenceNumber.appendChild(Code) |
4211 | +# |
4212 | +# Value = doc2.createElement("Value") |
4213 | +# ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["Package"][i]["ReferenceNumber"]["Value"]) |
4214 | +# Value.appendChild(ptext) |
4215 | +# ReferenceNumber.appendChild(Value) |
4216 | + |
4217 | + # AdditionalHandling = doc2.createElement("AdditionalHandling") |
4218 | + # ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["Package"][i]["AdditionalHandling"]) |
4219 | + # AdditionalHandling.appendChild(ptext) |
4220 | + # Package.appendChild(AdditionalHandling) |
4221 | + |
4222 | + # PackageServiceOptions = doc2.createElement("PackageServiceOptions") |
4223 | + # Package.appendChild(PackageServiceOptions) |
4224 | + # |
4225 | + # DeliveryConfirmation = doc2.createElement("DeliveryConfirmation") |
4226 | + # PackageServiceOptions.appendChild(DeliveryConfirmation) |
4227 | + # |
4228 | + # DCISType = doc2.createElement("DCISType") |
4229 | + # ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["Package"][i]["PackageServiceOptions"]['DeliveryConfirmation']['DCISType']) |
4230 | + # DCISType.appendChild(ptext) |
4231 | + # DeliveryConfirmation.appendChild(DCISType) |
4232 | + # |
4233 | + # DCISNumber = doc2.createElement("DCISNumber") |
4234 | + # ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["Package"][i]["PackageServiceOptions"]['DeliveryConfirmation']['DCISNumber']) |
4235 | + # DCISNumber.appendChild(ptext) |
4236 | + # DeliveryConfirmation.appendChild(DCISNumber) |
4237 | + # |
4238 | + # InsuredValue = doc2.createElement("InsuredValue") |
4239 | + # PackageServiceOptions.appendChild(InsuredValue) |
4240 | + # |
4241 | + # |
4242 | + # Type = doc2.createElement("Type") |
4243 | + # ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["Package"][i]["PackageServiceOptions"]['InsuredValue']['Type']) |
4244 | + # Type.appendChild(ptext) |
4245 | + # InsuredValue.appendChild(Type) |
4246 | + # |
4247 | + # Code = doc2.createElement("Code") |
4248 | + # ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["Package"][i]["PackageServiceOptions"]['InsuredValue']['Code']) |
4249 | + # Code.appendChild(ptext) |
4250 | + # InsuredValue.appendChild(Code) |
4251 | + # |
4252 | + # |
4253 | + # Description = doc2.createElement("Description") |
4254 | + # ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["Package"][i]["PackageServiceOptions"]['InsuredValue']['Description']) |
4255 | + # Description.appendChild(ptext) |
4256 | + # InsuredValue.appendChild(Description) |
4257 | + # |
4258 | + # Description = doc2.createElement("CurrencyCode") |
4259 | + # ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["Package"][i]["PackageServiceOptions"]['InsuredValue']['CurrencyCode']) |
4260 | + # CurrencyCode.appendChild(ptext) |
4261 | + # InsuredValue.appendChild(CurrencyCode) |
4262 | + # |
4263 | + # Description = doc2.createElement("MonetaryValue") |
4264 | + # ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["Package"][i]["PackageServiceOptions"]['InsuredValue']['MonetaryValue']) |
4265 | + # MonetaryValue.appendChild(ptext) |
4266 | + # InsuredValue.appendChild(MonetaryValue) |
4267 | + # |
4268 | + # |
4269 | + # COD = doc2.createElement("COD") |
4270 | + # PackageServiceOptions.appendChild(COD) |
4271 | + # |
4272 | + # |
4273 | + # CODCode = doc2.createElement("CODCode") |
4274 | + # ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["Package"][i]["PackageServiceOptions"]['COD']['CODCode']) |
4275 | + # CODCode.appendChild(ptext) |
4276 | + # COD.appendChild(CODCode) |
4277 | + # |
4278 | + # CODFundsCode = doc2.createElement("CODFundsCode") |
4279 | + # ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["Package"][i]["PackageServiceOptions"]['COD']['CODFundsCode']) |
4280 | + # CODFundsCode.appendChild(ptext) |
4281 | + # COD.appendChild(CODFundsCode) |
4282 | + # |
4283 | + # CODAmount = doc2.createElement("CODAmount") |
4284 | + # ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["Package"][i]["PackageServiceOptions"]['COD']['CODAmount']) |
4285 | + # CODAmount.appendChild(ptext) |
4286 | + # COD.appendChild(CODAmount) |
4287 | + # |
4288 | + # CurrencyCode = doc2.createElement("CurrencyCode") |
4289 | + # ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["Package"][i]["PackageServiceOptions"]['InsuredValue']['COD']['CODAmount']['CurrencyCode']) |
4290 | + # CurrencyCode.appendChild(ptext) |
4291 | + # InsuredValue.appendChild(CurrencyCode) |
4292 | + # |
4293 | + # MonetaryValue = doc2.createElement("MonetaryValue") |
4294 | + # ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["Package"][i]["PackageServiceOptions"]['InsuredValue']['COD']['CODAmount']['MonetaryValue']) |
4295 | + # MonetaryValue.appendChild(ptext) |
4296 | + # InsuredValue.appendChild(MonetaryValue) |
4297 | + # |
4298 | + # VerbalConfirmation = doc2.createElement("VerbalConfirmation") |
4299 | + # PackageServiceOptions.appendChild(VerbalConfirmation) |
4300 | + # |
4301 | + # ContactInfo = doc2.createElement("ContactInfo") |
4302 | + # VerbalConfirmation.appendChild(ContactInfo) |
4303 | + # |
4304 | + # Name = doc2.createElement("Name") |
4305 | + # ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["Package"][i]["PackageServiceOptions"]['VerbalConfirmation']['VerbalConfirmation']['Name']) |
4306 | + # Name.appendChild(ptext) |
4307 | + # ContactInfo.appendChild(Name) |
4308 | + # |
4309 | + # PhoneNumber = doc2.createElement("PhoneNumber") |
4310 | + # ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["Package"][i]["PackageServiceOptions"]['VerbalConfirmation']['VerbalConfirmation']['PhoneNumber']) |
4311 | + # PhoneNumber.appendChild(ptext) |
4312 | + # ContactInfo.appendChild(PhoneNumber) |
4313 | + # |
4314 | + # ShipperReleaseIndicator = doc2.createElement("ShipperReleaseIndicator") |
4315 | + # ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["Package"][i]["PackageServiceOptions"]['ShipperReleaseIndicator']) |
4316 | + # ShipperReleaseIndicator.appendChild(ptext) |
4317 | + # PackageServiceOptions.appendChild(ShipperReleaseIndicator) |
4318 | + # |
4319 | + # |
4320 | + # Notification = doc2.createElement("Notification") |
4321 | + # PackageServiceOptions.appendChild(Notification) |
4322 | + # NotificationCode = doc2.createElement("NotificationCode") |
4323 | + # ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["Package"][i]["PackageServiceOptions"]['Notification']) |
4324 | + # NotificationCode.appendChild(ptext) |
4325 | + # Notification.appendChild(NotificationCode) |
4326 | + # |
4327 | + # EMailMessage = doc2.createElement("EMailMessage") |
4328 | + # Notification.appendChild(EMailMessage) |
4329 | + # UndeliverableEMailAddress = doc2.createElement("UndeliverableEMailAddress") |
4330 | + # ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["Package"][i]["PackageServiceOptions"]["Notification"]["EMailMessage"]["UndeliverableEMailAddress"]) |
4331 | + # UndeliverableEMailAddress.appendChild(ptext) |
4332 | + # EMailMessage.appendChild(UndeliverableEMailAddress) |
4333 | + # |
4334 | + # EMailAddress = doc2.createElement("EMailAddress") |
4335 | + # ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["Package"][i]["PackageServiceOptions"]["Notification"]["EMailMessage"]["EMailAddress"]) |
4336 | + # EMailAddress.appendChild(ptext) |
4337 | + # EMailMessage.appendChild(EMailAddress) |
4338 | + # |
4339 | + # FromEMailAddress = doc2.createElement("FromEMailAddress") |
4340 | + # ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["Package"][i]["PackageServiceOptions"]["Notification"]["EMailMessage"]["FromEMailAddress"]) |
4341 | + # FromEMailAddress.appendChild(ptext) |
4342 | + # EMailMessage.appendChild(FromEMailAddress) |
4343 | + # |
4344 | + # FromName = doc2.createElement("FromName") |
4345 | + # ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["Package"][i]["PackageServiceOptions"]["Notification"]["EMailMessage"]["FromName"]) |
4346 | + # FromName.appendChild(ptext) |
4347 | + # EMailMessage.appendChild(FromName) |
4348 | + # |
4349 | + # Memo = doc2.createElement("Memo") |
4350 | + # ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["Package"][i]["PackageServiceOptions"]["Notification"]["EMailMessage"]["Memo"]) |
4351 | + # Memo.appendChild(ptext) |
4352 | + # EMailMessage.appendChild(Memo) |
4353 | + # |
4354 | + # Subject = doc2.createElement("Subject") |
4355 | + # ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["Package"][i]["PackageServiceOptions"]["Notification"]["EMailMessage"]["Subject"]) |
4356 | + # Subject.appendChild(ptext) |
4357 | + # EMailMessage.appendChild(Subject) |
4358 | + # |
4359 | + # SubjectCode = doc2.createElement("SubjectCode") |
4360 | + # ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["Package"][i]["PackageServiceOptions"]["Notification"]["EMailMessage"]["SubjectCode"]) |
4361 | + # SubjectCode.appendChild(ptext) |
4362 | + # EMailMessage.appendChild(SubjectCode) |
4363 | + # |
4364 | + # ReturnsFlexibleAccessIndicator = doc2.createElement("ReturnsFlexibleAccessIndicator") |
4365 | + # ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["Package"][i]["PackageServiceOptions"]['ReturnsFlexibleAccessIndicator']) |
4366 | + # ReturnsFlexibleAccessIndicator.appendChild(ptext) |
4367 | + # PackageServiceOptions.appendChild(ReturnsFlexibleAccessIndicator) |
4368 | + |
4369 | + |
4370 | + |
4371 | + |
4372 | + |
4373 | + |
4374 | + #/////////end loop in code |
4375 | + |
4376 | + |
4377 | + |
4378 | + LabelSpecification = doc2.createElement("LabelSpecification") |
4379 | + ShipmentConfirmRequest.appendChild(LabelSpecification) |
4380 | + |
4381 | + LabelPrintMethod = doc2.createElement("LabelPrintMethod") |
4382 | + LabelSpecification.appendChild(LabelPrintMethod) |
4383 | + Code = doc2.createElement("Code") |
4384 | + ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["LabelSpecification"]["LabelPrintMethod"]["Code"]) |
4385 | + Code.appendChild(ptext) |
4386 | + LabelPrintMethod.appendChild(Code) |
4387 | + |
4388 | + Description = doc2.createElement("Description") |
4389 | + ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["LabelSpecification"]["LabelPrintMethod"]["Description"]) |
4390 | + Description.appendChild(ptext) |
4391 | + LabelPrintMethod.appendChild(Description) |
4392 | + |
4393 | + # HTTPUserAgent = doc2.createElement("HTTPUserAgent") |
4394 | + # ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["LabelSpecification"]["LabelPrintMethod"]["HTTPUserAgent"]) |
4395 | + # HTTPUserAgent.appendChild(ptext) |
4396 | + # LabelSpecification.appendChild(HTTPUserAgent) |
4397 | + |
4398 | + LabelStockSize = doc2.createElement("LabelStockSize") |
4399 | + LabelSpecification.appendChild(LabelStockSize) |
4400 | + Height = doc2.createElement("Height") |
4401 | + ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["LabelSpecification"]["LabelStockSize"]["Height"]) |
4402 | + Height.appendChild(ptext) |
4403 | + LabelStockSize.appendChild(Height) |
4404 | + Width = doc2.createElement("Width") |
4405 | + ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["LabelSpecification"]["LabelStockSize"]["Width"]) |
4406 | + Width.appendChild(ptext) |
4407 | + LabelStockSize.appendChild(Width) |
4408 | + |
4409 | + LabelImageFormat = doc2.createElement("LabelImageFormat") |
4410 | + LabelSpecification.appendChild(LabelImageFormat) |
4411 | + |
4412 | + Code = doc2.createElement("Code") |
4413 | + ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["LabelSpecification"]["LabelImageFormat"]["Code"]) |
4414 | + Code.appendChild(ptext) |
4415 | + LabelImageFormat.appendChild(Code) |
4416 | + |
4417 | + Description = doc2.createElement("Description") |
4418 | + ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["LabelSpecification"]["LabelImageFormat"]["Description"]) |
4419 | + Description.appendChild(ptext) |
4420 | + LabelImageFormat.appendChild(Description) |
4421 | + |
4422 | + |
4423 | + request_string2=doc2.toprettyxml() |
4424 | + |
4425 | + request_string=Request_string1+request_string2 |
4426 | + |
4427 | + return request_string |
4428 | + |
4429 | + def _get_value(self,obj,template_obj,var): |
4430 | + try : |
4431 | + ret='' |
4432 | + temp1='template_obj.'+var |
4433 | + temp1=temp1.strip(' ') |
4434 | + temp1=eval(temp1) |
4435 | + if temp1 and '${' in temp1: |
4436 | + temp=temp1 |
4437 | + temp=''.join(temp.split('\n')) |
4438 | + temp_list=re.findall('\$\{.*?\}',temp) |
4439 | + for item in temp_list: |
4440 | + ret+=temp[0:temp.index(item)] |
4441 | + item=item.strip('') |
4442 | + list_item=item.strip('${') |
4443 | + list_item=list_item.strip('}') |
4444 | + list_item=list_item.split('object.') |
4445 | + ret+=eval('obj.'+list_item[-1]) or '' |
4446 | + temp=temp[temp.index(item)+len(item):] |
4447 | + ret+=temp |
4448 | + return ret |
4449 | + else: |
4450 | + return temp1 |
4451 | + except: |
4452 | + try: |
4453 | + return eval('template_obj.'+var) |
4454 | + except: |
4455 | + return '' |
4456 | + def send_conf_mail(self,cr,uid,ids,context=None): |
4457 | + val={} |
4458 | + for id in ids: |
4459 | + obj=self.browse(cr, uid, id) |
4460 | + if obj and obj.address_id and obj.address_id.email: |
4461 | + template_id=self.pool.get('email.template').search(cr,uid,[('object_name.model','=','stock.picking'),('ship_mail','=',True)] ) |
4462 | + if template_id: |
4463 | + template_obj_list=self.pool.get('email.template').browse(cr,uid,template_id) |
4464 | + for template_obj in template_obj_list: |
4465 | + vals={'email_to':self._get_value(obj,template_obj,'def_to') or '', |
4466 | + 'body_text':self._get_value(obj,template_obj,'def_body_text') or '', |
4467 | + 'body_html':self._get_value(obj,template_obj,'def_body_html') or '', |
4468 | + 'account_id':template_obj.from_account.id, |
4469 | + 'folder':'outbox', |
4470 | + 'state':'draft', |
4471 | + 'subject':self._get_value(obj,template_obj,'def_subject') or '', |
4472 | + 'email_cc':self._get_value(obj,template_obj,'def_cc') or '', |
4473 | + 'email_bcc':self._get_value(obj,template_obj,'def_bcc') or '', |
4474 | + 'email_from':template_obj.from_account.email_id or '', |
4475 | + 'reply_to':self._get_value(obj,template_obj,'reply_to') or '' , |
4476 | + 'date_mail':time.strftime('%Y-%m-%d %H:%M:%S'), |
4477 | + } |
4478 | + account = self.pool.get('email_template.mailbox').create(cr, uid,vals) |
4479 | + return True |
4480 | + |
4481 | + def process_ship(self,cr, uid, ids, context=None): |
4482 | + deliv_order = self.browse(cr, uid, type(ids)==type([]) and ids[0] or ids, context=context) |
4483 | + error_flag=False |
4484 | + ship_move_ids={} |
4485 | + do_transaction = True |
4486 | + response_dic = {} |
4487 | + if not (deliv_order.logis_company or deliv_order.shipper or deliv_order.ups_service): |
4488 | + raise osv.except_osv("Warning", "Please select Logistics Company, Shipper and Shipping Service") |
4489 | + if not deliv_order.packages_ids: |
4490 | + raise osv.except_osv("Warning", "Please add shipping packages before doing Process Shipping.") |
4491 | + if not deliv_order.invoiced and deliv_order.sale_id and deliv_order.sale_id.order_policy == 'credit_card' : |
4492 | + if not deliv_order.sale_id.cc_pre_auth: |
4493 | + raise osv.except_osv("Warning", "The sales order is not paid") |
4494 | + else: |
4495 | + do_transaction = False |
4496 | + rel_voucher_id = deliv_order.sale_id.rel_account_voucher_id |
4497 | + if rel_voucher_id and rel_voucher_id.state != 'posted' and deliv_order.sale_id.cc_pre_auth: |
4498 | + self.pool.get('account.voucher').write(cr,uid,[rel_voucher_id.id],{'cc_p_authorize':False,'cc_charge':True}, context=context) |
4499 | + do_transaction = self.pool.get('account.voucher').authorize(cr, uid, [rel_voucher_id.id], context=context) |
4500 | + if not do_transaction: |
4501 | + self.write(cr,uid,ids,{'ship_state':'hold','ship_message':'Unable to process creditcard payment.'}) |
4502 | + cr.commit() |
4503 | + raise osv.except_osv(_('Final credit card charge cannot be completed!'),_("Please hold shipment and contact customer service..") ) |
4504 | + warning_error = False |
4505 | + for pack_obj in deliv_order.packages_ids: |
4506 | + ship_confirm_request_xml=self.create_ship_confirm_request(cr, uid,pack_obj.id) |
4507 | + ship_confirm_web='' |
4508 | + ship_confirm_port='' |
4509 | + |
4510 | + if deliv_order.logis_company: |
4511 | + if deliv_order.logis_company.test_mode: |
4512 | + ship_confirm_web=deliv_order.logis_company.ship_req_test_web |
4513 | + ship_confirm_port=deliv_order.logis_company.ship_req_test_port |
4514 | + |
4515 | + else: |
4516 | + ship_confirm_web=deliv_order.logis_company.ship_req_web |
4517 | + ship_confirm_port=deliv_order.logis_company.ship_req_port |
4518 | + |
4519 | + if ship_confirm_web: |
4520 | + parse_url = urlparse(ship_confirm_web) |
4521 | + serv = parse_url.netloc |
4522 | + serv_path = parse_url.path |
4523 | + else: |
4524 | + raise osv.except_osv(_('Unable to find Shipping URL!'),_("Please configure the shipping company with websites.")) |
4525 | + |
4526 | + conn=httplib.HTTPSConnection(serv,ship_confirm_port) |
4527 | + res=conn.request("POST",serv_path,ship_confirm_request_xml) |
4528 | + """1.make and call function to send request/ 2.make function to process the response and write it """ |
4529 | + |
4530 | + |
4531 | + res=conn.getresponse() |
4532 | + result = res.read() |
4533 | + |
4534 | + response_dic=xml2dic.main(result) |
4535 | + |
4536 | + |
4537 | + response = '' |
4538 | + |
4539 | + if not response_dic: |
4540 | + continue |
4541 | + for res_elm in response_dic['ShipmentConfirmResponse'][0]['Response']: |
4542 | + if res_elm.get('ResponseStatusCode'): |
4543 | + response = '\nResponse Status Code: '+str(res_elm['ResponseStatusCode']) |
4544 | + if res_elm.get('ResponseStatusDescription'): |
4545 | + response += '\nResponse Description: '+str(res_elm['ResponseStatusDescription']) |
4546 | + if res_elm.get('Error'): |
4547 | + |
4548 | + error_flag =True |
4549 | + for err_elm in res_elm.get('Error'): |
4550 | + if err_elm.get('ErrorSeverity',False): |
4551 | + response += '\nErrorSeverity: '+str(err_elm['ErrorSeverity']) |
4552 | + if str(err_elm['ErrorSeverity']) == 'Warning': |
4553 | + warning_error = True |
4554 | + error_flag = False |
4555 | + if err_elm.get('ErrorCode',False): |
4556 | + response += '\nErrorCode: '+str(err_elm['ErrorCode']) |
4557 | + if err_elm.get('ErrorDescription',False): |
4558 | + response += '\nErrorDescription: '+str(err_elm['ErrorDescription']) |
4559 | + if err_elm.get('ErrorLocation',False): |
4560 | + response += '\nErrorLocation: '+str(err_elm['ErrorLocation']) |
4561 | + self.write(cr,uid,ids,{'ship_message':'Ship Processing:'+str(response)}) |
4562 | + if not warning_error: |
4563 | + break |
4564 | + temp="" |
4565 | + if len(response_dic['ShipmentConfirmResponse'])>5 and response_dic['ShipmentConfirmResponse'][5].has_key('ShipmentDigest') : |
4566 | + temp +=str(response_dic['ShipmentConfirmResponse'][5]['ShipmentDigest']) |
4567 | + self.pool.get('stock.packages').write(cr,uid,[pack_obj.id],{'ship_message':str(response),'shipment_digest':str(temp)}) |
4568 | + |
4569 | + |
4570 | + if int(time.strftime("%w")) in range(1,6) or (time.strftime("%w") == '6' and deliv_order.sat_delivery): |
4571 | + next_pic_date = time.strftime("%Y-%m-%d") |
4572 | + else: |
4573 | + timedelta = datetime.timedelta(7-int(time.strftime("%w"))) |
4574 | + next_pic_date = (datetime.datetime.today()+timedelta).strftime("%Y-%m-%d") |
4575 | + |
4576 | + value_dic={'pick_id':deliv_order.id , |
4577 | + 'package_weight':pack_obj.weight, |
4578 | + 'state':deliv_order.ship_state, |
4579 | + 'partner_id':deliv_order.address_id.id and deliv_order.address_id.partner_id.id, |
4580 | + 'service':deliv_order.ups_service.id, |
4581 | + 'ship_to':deliv_order.address_id.id, |
4582 | + 'ship_from':deliv_order.ship_from and deliv_order.ship_from_address.id or deliv_order.shipper.id and deliv_order.shipper.address.id, |
4583 | + 'package':pack_obj.description and str(pack_obj.description)[:126], |
4584 | + 'pic_date':next_pic_date, |
4585 | + 'sale_id':deliv_order.sale_id.id and deliv_order.sale_id.id or False, |
4586 | + } |
4587 | + if not error_flag: |
4588 | + ship_move_ids[pack_obj.id] = self.pool.get('shipping.move').create(cr, uid, value_dic) |
4589 | + self.process_ship_accept(cr, uid, ids,ship_move_ids,pack_obj,context=context) |
4590 | +# else: |
4591 | +# error_flag =True |
4592 | +# try: |
4593 | + if not error_flag: |
4594 | + if warning_error: |
4595 | + ship_msg = 'Shipping success with warning. Please see the individual package details.' |
4596 | + else: |
4597 | + ship_msg = 'Success' |
4598 | + self.write(cr,uid,ids,{'ship_state':'ready_pick','ship_message':ship_msg}) |
4599 | + try: |
4600 | + self.send_conf_mail(cr,uid,ids,context=context) |
4601 | + except Exception,e: |
4602 | + pass |
4603 | + if ship_move_ids: |
4604 | + self.pool.get('shipping.move').write(cr, uid, ship_move_ids.values(),{'state':'ready_pick'}) |
4605 | + return { |
4606 | + 'type': 'ir.actions.report.xml', |
4607 | + 'report_name':'multiple.label.print', |
4608 | + 'datas': { |
4609 | + 'model':'stock.picking', |
4610 | + 'id': ids and ids[0] or False, |
4611 | + 'ids': ids and ids or [], |
4612 | + 'report_type': 'pdf' |
4613 | + }, |
4614 | + 'nodestroy': True |
4615 | + } |
4616 | + |
4617 | + |
4618 | +# except Exception,e: |
4619 | +# pass |
4620 | + return True |
4621 | + |
4622 | + def _get_journal_id(self, cr, uid, ids, context={}): |
4623 | + journal_obj = self.pool.get('account.journal') |
4624 | + vals = [] |
4625 | + browse_picking = self.browse(cr, uid, ids, context=context) |
4626 | + |
4627 | + for pick in browse_picking: |
4628 | + src_usage = pick.move_lines[0].location_id.usage |
4629 | + dest_usage = pick.move_lines[0].location_dest_id.usage |
4630 | + type = pick.type |
4631 | + if type == 'out' and dest_usage == 'supplier': |
4632 | + journal_type = 'purchase_refund' |
4633 | + elif type == 'out' and dest_usage == 'customer': |
4634 | + journal_type = 'sale' |
4635 | + elif type == 'in' and src_usage == 'supplier': |
4636 | + journal_type = 'purchase' |
4637 | + elif type == 'in' and src_usage == 'customer': |
4638 | + journal_type = 'sale_refund' |
4639 | + else: |
4640 | + journal_type = 'sale' |
4641 | + |
4642 | + value = journal_obj.search(cr, uid, [('type', '=',journal_type )]) |
4643 | + for jr_type in journal_obj.browse(cr, uid, value, context=context): |
4644 | + t1 = jr_type.id,jr_type.name |
4645 | + if t1 not in vals: |
4646 | + vals.append(t1) |
4647 | + return vals |
4648 | + |
4649 | + |
4650 | + def do_partial(self, cr, uid, ids, partial_datas, context=None): |
4651 | + res = self._get_journal_id(cr, uid, ids, context=context) |
4652 | + result_partial = super(stock_picking, self).do_partial(cr, uid, ids, partial_datas, context=context) |
4653 | + if res and res[0]: |
4654 | + journal_id = res[0][0] |
4655 | + result = result_partial |
4656 | + stock_picking_objs = self.browse(cr, uid, ids, context=context) |
4657 | + for stock_picking_obj in stock_picking_objs: |
4658 | + if stock_picking_obj.sale_id and stock_picking_obj.sale_id.order_policy == 'picking': |
4659 | + pick_id = result_partial[stock_picking_obj.id]['delivered_picking'] |
4660 | + result = self.action_invoice_create(cr, uid, [pick_id], journal_id, type=None, context=context) |
4661 | + if len(stock_picking_obj.sale_id.invoice_ids)<=1 and result: |
4662 | + self.pool.get('account.invoice').write(cr, uid, result.values(),{'ship_method':stock_picking_obj.sale_id.ship_method, |
4663 | + 'shipcharge':stock_picking_obj.sale_id.shipcharge, |
4664 | + 'ship_method_id':stock_picking_obj.sale_id.ship_method_id and stock_picking_obj.sale_id.ship_method_id.id,}) |
4665 | + |
4666 | + |
4667 | + return result_partial |
4668 | +stock_picking() |
4669 | + |
4670 | + |
4671 | + |
4672 | +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: |
4673 | |
4674 | === added file 'shipping_api_ups/stock_package.py' |
4675 | --- shipping_api_ups/stock_package.py 1970-01-01 00:00:00 +0000 |
4676 | +++ shipping_api_ups/stock_package.py 2011-10-06 16:08:52 +0000 |
4677 | @@ -0,0 +1,92 @@ |
4678 | +# -*- coding: utf-8 -*- |
4679 | +############################################################################## |
4680 | +# |
4681 | +# OpenERP, Open Source Management Solution |
4682 | +# Copyright (C) 2011 NovaPoint Group LLC (<http://www.novapointgroup.com>) |
4683 | +# Copyright (C) 2004-2010 OpenERP SA (<http://www.openerp.com>) |
4684 | +# |
4685 | +# This program is free software: you can redistribute it and/or modify |
4686 | +# it under the terms of the GNU General Public License as published by |
4687 | +# the Free Software Foundation, either version 3 of the License, or |
4688 | +# (at your option) any later version. |
4689 | +# |
4690 | +# This program is distributed in the hope that it will be useful, |
4691 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
4692 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
4693 | +# GNU General Public License for more details. |
4694 | +# |
4695 | +# You should have received a copy of the GNU General Public License |
4696 | +# along with this program. If not, see <http://www.gnu.org/licenses/> |
4697 | +# |
4698 | +############################################################################## |
4699 | + |
4700 | + |
4701 | +from osv import fields,osv |
4702 | +from xml.dom.minidom import Document |
4703 | +import httplib |
4704 | +import xml2dic |
4705 | +import base64 |
4706 | + |
4707 | + |
4708 | +class stock_packages(osv.osv): |
4709 | + |
4710 | + def process_package(self,cr, uid, ids, context=None): |
4711 | + return True |
4712 | + |
4713 | + _inherit = "stock.packages" |
4714 | + _columns = { |
4715 | + 'shipment_digest': fields.text('ShipmentDigest'), |
4716 | + 'negotiated_rates': fields.float('NegotiatedRates'), |
4717 | + 'shipment_identific_no': fields.char('ShipmentIdentificationNumber', size=64, ), |
4718 | + 'tracking_no': fields.char('TrackingNumber', size=64, ), |
4719 | + 'logo':fields.binary('Label'), |
4720 | + 'ship_message':fields.text('Status Message'), |
4721 | + 'tracking_url':fields.char('Tracking URL', size=512, ), |
4722 | + } |
4723 | + _defaults = {'packge_no': False |
4724 | + } |
4725 | + |
4726 | + def onchange_weight(self, cr, uid, ids, line_ids, tot_order_weight, weight,context={}): |
4727 | + ''' |
4728 | + Function to automatically fill package weight |
4729 | + ''' |
4730 | + ret = {} |
4731 | + if weight: |
4732 | + ret['weight'] = weight |
4733 | + else: |
4734 | + used_weight = 0 |
4735 | + for line in line_ids: |
4736 | + if line and line[2] and line[2]['weight']: |
4737 | + used_weight += line[2]['weight'] |
4738 | + if used_weight < tot_order_weight: |
4739 | + ret['weight'] = tot_order_weight - used_weight |
4740 | + return {'value':ret} |
4741 | + def onchange_packge_no(self, cr, uid, ids, line_ids,packge_no,context={}): |
4742 | + ''' |
4743 | + Function to generate sequence on packages |
4744 | + ''' |
4745 | + ret = {} |
4746 | + if packge_no: |
4747 | + ret['packge_no'] = packge_no |
4748 | + else: |
4749 | + for line in line_ids: |
4750 | + if line and line[2] and line[2]['packge_no'] and packge_no < line[2]['packge_no']: |
4751 | + packge_no=line[2]['packge_no'] |
4752 | + packge_no+=1 |
4753 | + ret['packge_no'] = packge_no |
4754 | + return {'value':ret} |
4755 | + def print_label(self, cr, uid, ids, context=None): |
4756 | + if not ids: return [] |
4757 | + return { |
4758 | + 'type': 'ir.actions.report.xml', |
4759 | + 'report_name':'ship.label.print', |
4760 | + 'datas': { |
4761 | + 'model':'stock.packages', |
4762 | + 'id': ids and ids[0] or False, |
4763 | + 'ids': ids and ids or [], |
4764 | + 'report_type': 'pdf' |
4765 | + }, |
4766 | + 'nodestroy': True |
4767 | + } |
4768 | + |
4769 | +stock_packages() |
4770 | \ No newline at end of file |
4771 | |
4772 | === added file 'shipping_api_ups/stock_package_view.xml' |
4773 | --- shipping_api_ups/stock_package_view.xml 1970-01-01 00:00:00 +0000 |
4774 | +++ shipping_api_ups/stock_package_view.xml 2011-10-06 16:08:52 +0000 |
4775 | @@ -0,0 +1,107 @@ |
4776 | +<?xml version="1.0" encoding="UTF-8"?> |
4777 | +<openerp> |
4778 | + <data> |
4779 | + |
4780 | + <record id="stock_packages_tree" model="ir.ui.view"> |
4781 | + <field name="name">stock.packages.tree</field> |
4782 | + <field name="model">stock.packages</field> |
4783 | + <field name="type">tree</field> |
4784 | + <field name="arch" type="xml"> |
4785 | + <tree editable="bottom" string='Shipping Packages'> |
4786 | + <field name='packge_no' on_change="onchange_packge_no(parent.packages_ids,packge_no)"/> |
4787 | + <field name='weight' on_change="onchange_weight(parent.packages_ids, parent.tot_del_order_weight, weight)"/> |
4788 | + <field name='package_type'/> |
4789 | + <field name='length'/> |
4790 | + <field name='width'/> |
4791 | + <field name='height'/> |
4792 | + <field name='decl_val'/> |
4793 | + <field name='ref1'/> |
4794 | + <field name='ref2'/> |
4795 | + <field name='negotiated_rates' readonly="1"/> |
4796 | + <field name='shipment_identific_no' readonly="1"/> |
4797 | + <field name='tracking_no' readonly="1"/> |
4798 | + <button string="Print Label" name="print_label" type="object" help='This prints a specific label for the package. This button also allows for reprinting a button. The label is stored in the document management system as a pdf.'/> |
4799 | + |
4800 | + </tree> |
4801 | + </field> |
4802 | + </record> |
4803 | + |
4804 | + <!--Form view for Ups Stock Package--> |
4805 | + |
4806 | + <record id="stock_packages_form" model="ir.ui.view"> |
4807 | + <field name="name">stock.packages.form</field> |
4808 | + <field name="model">stock.packages</field> |
4809 | + <field name="type">form</field> |
4810 | + <field name="arch" type="xml"> |
4811 | + <form string='Shipping Packages'> |
4812 | + <group colspan="4" col="4" string=""> |
4813 | + <field name='packge_no' on_change="onchange_packge_no(parent.packages_ids,packge_no)"/> |
4814 | + <field name='description'/> |
4815 | + <field name='weight' on_change="onchange_weight(parent.packages_ids,parent.tot_del_order_weight, weight)"/> |
4816 | + <field name='package_type'/> |
4817 | + <field name='length'/> |
4818 | + <field name='width'/> |
4819 | + <field name='height'/> |
4820 | + <field name='decl_val'/> |
4821 | + <field name='ref1'/> |
4822 | + <field name='ref2'/><newline/> |
4823 | + <button string="Weigh" help='Click this button to weigh the package from the scale.'/> |
4824 | + <label colspan="2"/><button string="Print Label" name="print_label" type="object" help='This prints a specific label for the package. This button also allows for reprinting a button. The label is stored in the document management system as a pdf.'/> |
4825 | + </group> |
4826 | + <newline/> |
4827 | + <group string="Shipment Status"> |
4828 | + <field name='ship_message'/> |
4829 | + </group> |
4830 | + <newline/> |
4831 | + <group string="Shipping Results Details"> |
4832 | + <field name='negotiated_rates' readonly="1"/> |
4833 | + <field name='shipment_identific_no' readonly="1"/> |
4834 | + <field name='tracking_no' readonly="1"/> |
4835 | + <field name='tracking_url' readonly="1" widget="url"/> |
4836 | + <field name='logo' widget="image" readonly="1"/> |
4837 | + </group> |
4838 | + |
4839 | + </form> |
4840 | + </field> |
4841 | + </record> |
4842 | + |
4843 | + |
4844 | + |
4845 | + |
4846 | + |
4847 | + |
4848 | + |
4849 | + <record id="view_picking_ups_shipping_move_inherit" model="ir.ui.view"> |
4850 | + <field name="name">view_picking_ups_shipping_move_inherit</field> |
4851 | + <field name="model">shipping.move</field> |
4852 | + <field name="inherit_id" ref="shipping_api.shipping_move_form"/> |
4853 | + <field name="type">form</field> |
4854 | + <field name="arch" type="xml"> |
4855 | + <xpath expr="//field[@name='ship_date']" position="after"> |
4856 | + <field name='shipment_identific_no' readonly="1"/> |
4857 | + <field name='logo' widget="image" readonly="1"/> |
4858 | + <field name='tracking_url' widget="url" readonly="1"/> |
4859 | + <button string="Print Label" name="print_label" type="object" help='This prints a specific label for the package. This button also allows for reprinting a button. The label is stored in the document management system as a pdf.'/> |
4860 | + <newline/> |
4861 | + </xpath> |
4862 | + </field> |
4863 | + </record> |
4864 | + |
4865 | +<!-- Email Template --> |
4866 | + <record model="ir.ui.view" id="email_template_form_inherit"> |
4867 | + <field name="name">email.template.form.inherit</field> |
4868 | + <field name="model">email.template</field> |
4869 | + <field name="type">form</field> |
4870 | + <field name="inherit_id" ref="email_template.email_template_form" /> |
4871 | + <field name="arch" type="xml"> |
4872 | + <field name="track_campaign_item" colspan="4" position="after"> |
4873 | + <field name="ship_mail" colspan="4" /> |
4874 | + </field> |
4875 | + </field> |
4876 | + </record> |
4877 | + |
4878 | + |
4879 | + |
4880 | + </data> |
4881 | +</openerp> |
4882 | + |
4883 | |
4884 | === added file 'shipping_api_ups/ups.py' |
4885 | --- shipping_api_ups/ups.py 1970-01-01 00:00:00 +0000 |
4886 | +++ shipping_api_ups/ups.py 2011-10-06 16:08:52 +0000 |
4887 | @@ -0,0 +1,110 @@ |
4888 | +# -*- coding: utf-8 -*- |
4889 | +############################################################################## |
4890 | +# |
4891 | +# OpenERP, Open Source Management Solution |
4892 | +# Copyright (C) 2011 NovaPoint Group LLC (<http://www.novapointgroup.com>) |
4893 | +# Copyright (C) 2004-2010 OpenERP SA (<http://www.openerp.com>) |
4894 | +# |
4895 | +# This program is free software: you can redistribute it and/or modify |
4896 | +# it under the terms of the GNU General Public License as published by |
4897 | +# the Free Software Foundation, either version 3 of the License, or |
4898 | +# (at your option) any later version. |
4899 | +# |
4900 | +# This program is distributed in the hope that it will be useful, |
4901 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
4902 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
4903 | +# GNU General Public License for more details. |
4904 | +# |
4905 | +# You should have received a copy of the GNU General Public License |
4906 | +# along with this program. If not, see <http://www.gnu.org/licenses/> |
4907 | +# |
4908 | +############################################################################## |
4909 | + |
4910 | +from osv import fields,osv |
4911 | +import re |
4912 | + |
4913 | + |
4914 | + |
4915 | +class ups_account_shipping(osv.osv): |
4916 | + _name = "ups.account.shipping" |
4917 | + _columns = { |
4918 | + 'name':fields.char('Name', size=64, required=True, select=1), |
4919 | + 'atten_name':fields.char('AttentionName', size=64, required=True, select=1), |
4920 | + 'accesslicensenumber': fields.char('AccessLicenseNumber', size= 64, required=True, select=1), |
4921 | + 'userid': fields.char('UserId',size=64 , required=True, select=1), |
4922 | + 'password': fields.char('Password', size=64, required=True, select=1), |
4923 | + 'active':fields.boolean('Active', size=64,), |
4924 | + 'acc_no':fields.char('Account Number',size=64 , required=True, select=1, help="Shipper's six digit account number."), |
4925 | + 'tax_id_no':fields.char('Tax Identification Number',size=64 , select=1, help="Shipper's Tax Identification Number."), |
4926 | + 'logistic_company_id':fields.many2one('logistic.company','Parent Logistic Company'), |
4927 | + 'ups_shipping_service_ids':fields.one2many('ups.shipping.service.type','ups_account_id','Shipping Service'), |
4928 | + 'address':fields.many2one('res.partner.address','Shipper Address'), |
4929 | + 'trademark':fields.char('Trademark', size=1024, select=1), |
4930 | + } |
4931 | + _defaults={ |
4932 | + 'active':True |
4933 | + } |
4934 | +ups_account_shipping() |
4935 | + |
4936 | + |
4937 | +class ups_account_shipping_service(osv.osv): |
4938 | + _name = "ups.shipping.service.type" |
4939 | + _rec_name = "description" |
4940 | + _columns = { |
4941 | + 'description': fields.char('Description', size=32, required=True, select=1), |
4942 | + 'category': fields.char('Category', size=32, select=1), |
4943 | + 'shipping_service_code': fields.char('Shipping Service Code', size=8, select=1), |
4944 | + 'rating_service_code': fields.char('Rating Service Code', size=8, select=1), |
4945 | + 'ups_account_id':fields.many2one('ups.account.shipping','Parent Shipping Account'), |
4946 | + } |
4947 | +ups_account_shipping_service() |
4948 | + |
4949 | + |
4950 | + |
4951 | + |
4952 | +class logistic_company(osv.osv): |
4953 | + _name = "logistic.company" |
4954 | + _inherit="logistic.company" |
4955 | + _columns = { |
4956 | + 'company_id':fields.many2one('res.company','Company'), |
4957 | + 'ups_shipping_account_ids': fields.one2many('ups.account.shipping','logistic_company_id','Shipping Account'), |
4958 | + } |
4959 | + |
4960 | + |
4961 | + def onchange_shipping_number(self, cr, uid, ids, shipping_no,url,context=None): |
4962 | + ret={} |
4963 | + if url: |
4964 | + b=url[url.rindex('/'):len(url)] |
4965 | + b=b.strip('/') |
4966 | + if re.match("^[0-9]*$",b): |
4967 | + url=url[0:url.rindex('/')] |
4968 | + url+=('/'+shipping_no) |
4969 | + ret['url']=url |
4970 | + return{'value':ret} |
4971 | + |
4972 | +logistic_company() |
4973 | + |
4974 | + |
4975 | +class res_company(osv.osv): |
4976 | + _inherit = "res.company" |
4977 | + _columns = { |
4978 | + 'logistic_company_ids': fields.one2many('logistic.company','company_id','Shipping Account'), |
4979 | + } |
4980 | + |
4981 | +res_company() |
4982 | + |
4983 | + |
4984 | +class shipping_move(osv.osv): |
4985 | + _inherit = "shipping.move" |
4986 | + _columns = { |
4987 | + 'shipper': fields.many2one('ups.account.shipping','Shipper',help='The specific user ID and shipper. Setup in the company configuration.'), |
4988 | + } |
4989 | +shipping_move() |
4990 | + |
4991 | + |
4992 | + |
4993 | + |
4994 | + |
4995 | + |
4996 | + |
4997 | +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: |
4998 | \ No newline at end of file |
4999 | |
5000 | === added file 'shipping_api_ups/ups_view.xml' |
Hello,
Thank you for this good contribution. I checked your branches and I would suggest to keep them in your own branch for now on, instead of putting them in the official release. Please register them in apps.openerp.com if it's not already done; if people use them in v6.1, we will think about merging them to the official branch.
As these modules have thousands lines of code, we would not have the time to efficiently review the code, check the usability experience and test for v6.1. I propose to review this later on, if we see people using it from apps.
Thanks,