Merge lp:~npg-team/openobject-addons/shipping_api_ups_npg into lp:openobject-addons

Proposed by Novapoint Group
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
Reviewer Review Type Date Requested Status
Olivier Dony (Odoo) policy + quick technical scan Disapprove
Review via email: mp+78439@code.launchpad.net

Description of the change

NovaPoint Group has developed this module to provide an UPS extension for the shipping api

To post a comment you must log in.
Revision history for this message
Fabien (Open ERP) (fp-tinyerp) wrote :

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,

Revision history for this message
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://bit.ly/openerp-contrib-mp

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!

review: Disapprove (policy + quick technical scan)

Unmerged revisions

5306. By Novapoint Group

[Add]: shipping_api_us module to provide an interface for UPS shipping

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== added directory 'shipping_api_ups'
=== added file 'shipping_api_ups/Change Log.txt'
--- shipping_api_ups/Change Log.txt 1970-01-01 00:00:00 +0000
+++ shipping_api_ups/Change Log.txt 2011-10-06 16:08:52 +0000
@@ -0,0 +1,41 @@
1===============================================================================
2 Version Change Log (shipping_api_ups)
3===============================================================================
41.15 (2011-08-19) by Arif
5 * Added validation on shipment process for sale order of CC
61.14 (2011-08-10)
7 * Removed dependancy to account_payment_creditcard
81.13 (2011-07-06) By Jabir
9 * Add validation of checking shipping packages before doing process shipping
10
111.12 (2011-07-06) By Jabir
12 * Updated shipping charge for first invoice created from delivery order
131.11 (2011-07-04) By Jabir
14 * Integrated Canada shipping documents
151.9 -> 1.10 (2011-06-10) By Jabir
16 * Automatically create invoice from delivery order if sale order is invoice from picking
171.8 -> 1.9 (2011-06-10) By Jabir
18 * Created security rules for models
19 * Updated package weight
20Version 1.6 -> 1.7
21 * Fixed the issue with error in Processed Shipping on Delivery Order
22Version 1.5 -> 1.6
23 * Fixed the issue with error in Processed Shipping on Delivery Order
24Version 1.4 -> 1.5
25 * Moved the credti card charging of pre-authorised payment from shipping to process button on delivery order.
26Version 1.3 -> 1.4
27 * Changed the wizard print summary report from old type to new orm.memory type
28Version 1.02 -> 1.03
29 *Adding shipping date into Shipping log
30
31Version 1.01 -> 1.02
32 * Changed the wizard update_shipping_status from old type to new orm.memory type
33Version 1.00 -> 1.01
34 * Fixed direct delivery order creating creating issue
35Version 1.0
36 * Created shipping label report
37 * Created Quick ship wizard
38 * Wizard to print summary report
39 * Wizard to update the status of shipping log
40 * Shipping using ups api
41 * Summary report
042
=== added file 'shipping_api_ups/__init__.py'
--- shipping_api_ups/__init__.py 1970-01-01 00:00:00 +0000
+++ shipping_api_ups/__init__.py 2011-10-06 16:08:52 +0000
@@ -0,0 +1,29 @@
1# -*- coding: utf-8 -*-
2##############################################################################
3#
4# OpenERP, Open Source Management Solution
5# Copyright (C) 2011 NovaPoint Group LLC (<http://www.novapointgroup.com>)
6# Copyright (C) 2004-2010 OpenERP SA (<http://www.openerp.com>)
7#
8# This program is free software: you can redistribute it and/or modify
9# it under the terms of the GNU General Public License as published by
10# the Free Software Foundation, either version 3 of the License, or
11# (at your option) any later version.
12#
13# This program is distributed in the hope that it will be useful,
14# but WITHOUT ANY WARRANTY; without even the implied warranty of
15# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16# GNU General Public License for more details.
17#
18# You should have received a copy of the GNU General Public License
19# along with this program. If not, see <http://www.gnu.org/licenses/>
20#
21##############################################################################
22
23import ups
24import stock
25import wizard
26import stock_package
27import report
28import sale
29# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
0\ No newline at end of file30\ No newline at end of file
131
=== added file 'shipping_api_ups/__openerp__.py'
--- shipping_api_ups/__openerp__.py 1970-01-01 00:00:00 +0000
+++ shipping_api_ups/__openerp__.py 2011-10-06 16:08:52 +0000
@@ -0,0 +1,52 @@
1# -*- coding: utf-8 -*-
2##############################################################################
3#
4# OpenERP, Open Source Management Solution
5# Copyright (C) 2011 NovaPoint Group LLC (<http://www.novapointgroup.com>)
6# Copyright (C) 2004-2010 OpenERP SA (<http://www.openerp.com>)
7#
8# This program is free software: you can redistribute it and/or modify
9# it under the terms of the GNU General Public License as published by
10# the Free Software Foundation, either version 3 of the License, or
11# (at your option) any later version.
12#
13# This program is distributed in the hope that it will be useful,
14# but WITHOUT ANY WARRANTY; without even the implied warranty of
15# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16# GNU General Public License for more details.
17#
18# You should have received a copy of the GNU General Public License
19# along with this program. If not, see <http://www.gnu.org/licenses/>
20#
21##############################################################################
22
23{
24 'name': 'Shipping API',
25 'version': '1.15',
26 'category': 'Generic Modules/Others',
27 'description': """
28 """,
29 'author': 'NovaPoint Group LLC',
30 'website': ' http://www.novapointgroup.com',
31 'depends': ['base','sale','sale_weight',
32 'stock','shipping_api',
33 'partner_address_validation',
34 'email_template',
35 'sale_negotiated_shipping'],
36 'init_xml': [],
37 'update_xml': [
38 'wizard/update_shipping_view.xml',
39 'wizard/summary_report_view.xml',
40 'wizard/quick_ship_view.xml',
41 'ups_view.xml',
42 'stock_package_view.xml',
43 'shipping_report.xml',
44 'security/ir.model.access.csv',
45
46 ],
47 'demo_xml': [
48 ],
49 'installable': True,
50 'active': False,
51}
52# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
053
=== added directory 'shipping_api_ups/report'
=== added file 'shipping_api_ups/report/__init__.py'
--- shipping_api_ups/report/__init__.py 1970-01-01 00:00:00 +0000
+++ shipping_api_ups/report/__init__.py 2011-10-06 16:08:52 +0000
@@ -0,0 +1,25 @@
1# -*- coding: utf-8 -*-
2##############################################################################
3#
4# OpenERP, Open Source Management Solution
5# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
6#
7# This program is free software: you can redistribute it and/or modify
8# it under the terms of the GNU Affero General Public License as
9# published by the Free Software Foundation, either version 3 of the
10# License, or (at your option) any later version.
11#
12# This program is distributed in the hope that it will be useful,
13# but WITHOUT ANY WARRANTY; without even the implied warranty of
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15# GNU Affero General Public License for more details.
16#
17# You should have received a copy of the GNU Affero General Public License
18# along with this program. If not, see <http://www.gnu.org/licenses/>.
19#
20##############################################################################
21
22import label_print
23import summary_report
24# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
25
026
=== added file 'shipping_api_ups/report/label_print.py'
--- shipping_api_ups/report/label_print.py 1970-01-01 00:00:00 +0000
+++ shipping_api_ups/report/label_print.py 2011-10-06 16:08:52 +0000
@@ -0,0 +1,62 @@
1# -*- coding: utf-8 -*-
2##############################################################################
3#
4# OpenERP, Open Source Management Solution
5# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
6#
7# This program is free software: you can redistribute it and/or modify
8# it under the terms of the GNU Affero General Public License as
9# published by the Free Software Foundation, either version 3 of the
10# License, or (at your option) any later version.
11#
12# This program is distributed in the hope that it will be useful,
13# but WITHOUT ANY WARRANTY; without even the implied warranty of
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15# GNU Affero General Public License for more details.
16#
17# You should have received a copy of the GNU Affero General Public License
18# along with this program. If not, see <http://www.gnu.org/licenses/>.
19#
20##############################################################################
21
22import time
23from report import report_sxw
24from tools import amount_to_text_en
25
26class report_print_label(report_sxw.rml_parse):
27 def __init__(self, cr, uid, name, context):
28 super(report_print_label, self).__init__(cr, uid, name, context)
29 self.number_lines = 0
30 self.number_add = 0
31 self.localcontext.update({
32 'time': time,
33 })
34
35
36
37
38report_sxw.report_sxw(
39 'report.ship.label.print',
40 'stock.packages',
41 'addons/shipping_api_ups/report/label_print.rml',
42 parser=report_print_label,header=False
43)
44report_sxw.report_sxw(
45 'report.ship.log.label.print',
46 'shipping.move',
47 'addons/shipping_api_ups/report/label_print.rml',
48 parser=report_print_label,header=False
49)
50report_sxw.report_sxw(
51 'report.quick.ship.label.print',
52 'quick.ship',
53 'addons/shipping_api_ups/report/label_print.rml',
54 parser=report_print_label,header=False
55)
56report_sxw.report_sxw(
57 'report.multiple.label.print',
58 'stock.picking',
59 'addons/shipping_api_ups/report/multiple_label_print.rml',
60 parser=report_print_label,header=False
61)
62# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
063
=== added file 'shipping_api_ups/report/label_print.rml'
--- shipping_api_ups/report/label_print.rml 1970-01-01 00:00:00 +0000
+++ shipping_api_ups/report/label_print.rml 2011-10-06 16:08:52 +0000
@@ -0,0 +1,59 @@
1<?xml version="1.0"?>
2<document filename="test.pdf">
3 <template pageSize="(308.0,434.0)" title="Test" author="Martin Simon" allowSplitting="20">
4 <pageTemplate id="first">
5 <frame id="first" x1="-98.0" y1="-30" width="500" height="468"/>
6 </pageTemplate>
7 </template>
8 <stylesheet>
9 <blockTableStyle id="Standard_Outline">
10 <blockAlignment value="LEFT"/>
11 <blockValign value="TOP"/>
12 </blockTableStyle>
13 <blockTableStyle id="Table1">
14 <blockAlignment value="LEFT"/>
15 <blockValign value="TOP"/>
16 </blockTableStyle>
17 <initialize>
18 <paraStyle name="all" alignment="justify"/>
19 </initialize>
20 <paraStyle name="P1" fontName="Times-Roman" fontSize="9.0" leading="11"/>
21 <paraStyle name="P2" rightIndent="0.0" leftIndent="0.0" fontName="Helvetica" fontSize="8.0" leading="10" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/>
22 <paraStyle name="Standard" fontName="Times-Roman"/>
23 <paraStyle name="Heading" fontName="Helvetica" fontSize="12.0" leading="15" spaceBefore="12.0" spaceAfter="6.0"/>
24 <paraStyle name="Text body" fontName="Times-Roman" spaceBefore="0.0" spaceAfter="6.0"/>
25 <paraStyle name="List" fontName="Times-Roman" spaceBefore="0.0" spaceAfter="6.0"/>
26 <paraStyle name="Caption" fontName="Times-Roman" fontSize="12.0" leading="15" spaceBefore="6.0" spaceAfter="6.0"/>
27 <paraStyle name="Index" fontName="Times-Roman"/>
28 <paraStyle name="Table Contents" fontName="Times-Roman" spaceBefore="0.0" spaceAfter="6.0"/>
29 <paraStyle name="Table Heading" fontName="Times-Roman" alignment="CENTER" spaceBefore="0.0" spaceAfter="6.0"/>
30 <paraStyle name="Footer" fontName="Times-Roman"/>
31 <paraStyle name="Horizontal Line" fontName="Times-Roman" fontSize="6.0" leading="8" spaceBefore="0.0" spaceAfter="14.0"/>
32 <paraStyle name="terp_header" fontName="Helvetica-Bold" fontSize="15.0" leading="19" alignment="LEFT" spaceBefore="12.0" spaceAfter="6.0"/>
33 <paraStyle name="Heading 9" fontName="Helvetica-Bold" fontSize="75%" leading="NaN" spaceBefore="12.0" spaceAfter="6.0"/>
34 <paraStyle name="terp_tblheader_General" fontName="Helvetica-Bold" fontSize="8.0" leading="10" alignment="LEFT" spaceBefore="6.0" spaceAfter="6.0"/>
35 <paraStyle name="terp_tblheader_Details" fontName="Helvetica-Bold" fontSize="9.0" leading="11" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/>
36 <paraStyle name="terp_default_8" fontName="Helvetica" fontSize="8.0" leading="10" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/>
37 <paraStyle name="terp_default_Bold_8" fontName="Helvetica-Bold" fontSize="8.0" leading="10" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/>
38 <paraStyle name="terp_tblheader_General_Centre" fontName="Helvetica-Bold" fontSize="8.0" leading="10" alignment="CENTER" spaceBefore="6.0" spaceAfter="6.0"/>
39 <paraStyle name="terp_tblheader_General_Right" fontName="Helvetica-Bold" fontSize="8.0" leading="10" alignment="RIGHT" spaceBefore="6.0" spaceAfter="6.0"/>
40 <paraStyle name="terp_tblheader_Details_Centre" fontName="Helvetica-Bold" fontSize="9.0" leading="11" alignment="CENTER" spaceBefore="0.0" spaceAfter="0.0"/>
41 <paraStyle name="terp_tblheader_Details_Right" fontName="Helvetica-Bold" fontSize="9.0" leading="11" alignment="RIGHT" spaceBefore="0.0" spaceAfter="0.0"/>
42 <paraStyle name="terp_default_Right_8" fontName="Helvetica" fontSize="8.0" leading="10" alignment="RIGHT" spaceBefore="0.0" spaceAfter="0.0"/>
43 <paraStyle name="terp_default_Centre_8" fontName="Helvetica" fontSize="8.0" leading="10" alignment="CENTER" spaceBefore="0.0" spaceAfter="0.0"/>
44 <paraStyle name="terp_header_Right" fontName="Helvetica-Bold" fontSize="15.0" leading="19" alignment="LEFT" spaceBefore="12.0" spaceAfter="6.0"/>
45 <paraStyle name="terp_header_Centre" fontName="Helvetica-Bold" fontSize="15.0" leading="19" alignment="CENTER" spaceBefore="12.0" spaceAfter="6.0"/>
46 <paraStyle name="terp_default_address" fontName="Helvetica" fontSize="10.0" leading="13" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/>
47 <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"/>
48 <paraStyle name="terp_default_Bold_9" fontName="Helvetica-Bold" fontSize="9.0" leading="11" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/>
49 <paraStyle name="terp_default_Centre_9" fontName="Helvetica" fontSize="9.0" leading="11" alignment="CENTER" spaceBefore="0.0" spaceAfter="0.0"/>
50 <paraStyle name="terp_default_Right_9" fontName="Helvetica" fontSize="9.0" leading="11" alignment="RIGHT" spaceBefore="0.0" spaceAfter="0.0"/>
51 <paraStyle name="terp_default_2" fontName="Helvetica" fontSize="2.0" leading="3" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/>
52 <images/>
53 </stylesheet>
54 <story>
55 <para style="P1">[[ repeatIn(objects,'o') ]]</para>
56 <para style="P2">[[ o.logo and setTag('para','image',{'width':'300','height':'450'}) or removeParentNode('blockTable') ]][[ o.logo ]]</para>
57 </story>
58</document>
59
060
=== added file 'shipping_api_ups/report/label_print.sxw'
1Binary 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 differ61Binary 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
=== added file 'shipping_api_ups/report/multiple_label_print.rml'
--- shipping_api_ups/report/multiple_label_print.rml 1970-01-01 00:00:00 +0000
+++ shipping_api_ups/report/multiple_label_print.rml 2011-10-06 16:08:52 +0000
@@ -0,0 +1,67 @@
1<?xml version="1.0"?>
2<document filename="test.pdf">
3 <template pageSize="(308.0,434.0)" title="Test" author="Martin Simon" allowSplitting="20">
4 <pageTemplate id="first">
5 <frame id="first" x1="-98.0" y1="-30" width="500" height="468"/>
6 </pageTemplate>
7 </template>
8 <stylesheet>
9 <blockTableStyle id="Standard_Outline">
10 <blockAlignment value="LEFT"/>
11 <blockValign value="TOP"/>
12 </blockTableStyle>
13 <blockTableStyle id="Table1">
14 <blockAlignment value="LEFT"/>
15 <blockValign value="TOP"/>
16 </blockTableStyle>
17 <initialize>
18 <paraStyle name="all" alignment="justify"/>
19 </initialize>
20 <paraStyle name="P1" rightIndent="0.0" leftIndent="0.0" fontName="Helvetica" fontSize="8.0" leading="10" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/>
21 <paraStyle name="P2" fontName="Times-Roman" fontSize="9.0" leading="11"/>
22 <paraStyle name="P3" rightIndent="0.0" leftIndent="-4.0" fontName="Times-Roman" fontSize="9.0" leading="11"/>
23 <paraStyle name="P4" rightIndent="0.0" leftIndent="0.0" fontName="Helvetica" fontSize="8.0" leading="10" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/>
24 <paraStyle name="P5" rightIndent="0.0" leftIndent="0.0" fontName="Helvetica" fontSize="8.0" leading="10" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/>
25 <paraStyle name="Standard" fontName="Times-Roman"/>
26 <paraStyle name="Heading" fontName="Helvetica" fontSize="12.0" leading="15" spaceBefore="12.0" spaceAfter="6.0"/>
27 <paraStyle name="Text body" fontName="Times-Roman" spaceBefore="0.0" spaceAfter="6.0"/>
28 <paraStyle name="List" fontName="Times-Roman" spaceBefore="0.0" spaceAfter="6.0"/>
29 <paraStyle name="Caption" fontName="Times-Roman" fontSize="12.0" leading="15" spaceBefore="6.0" spaceAfter="6.0"/>
30 <paraStyle name="Index" fontName="Times-Roman"/>
31 <paraStyle name="Table Contents" fontName="Times-Roman" spaceBefore="0.0" spaceAfter="6.0"/>
32 <paraStyle name="Table Heading" fontName="Times-Roman" alignment="CENTER" spaceBefore="0.0" spaceAfter="6.0"/>
33 <paraStyle name="Footer" fontName="Times-Roman"/>
34 <paraStyle name="Horizontal Line" fontName="Times-Roman" fontSize="6.0" leading="8" spaceBefore="0.0" spaceAfter="14.0"/>
35 <paraStyle name="terp_header" fontName="Helvetica-Bold" fontSize="15.0" leading="19" alignment="LEFT" spaceBefore="12.0" spaceAfter="6.0"/>
36 <paraStyle name="Heading 9" fontName="Helvetica-Bold" fontSize="75%" leading="NaN" spaceBefore="12.0" spaceAfter="6.0"/>
37 <paraStyle name="terp_tblheader_General" fontName="Helvetica-Bold" fontSize="8.0" leading="10" alignment="LEFT" spaceBefore="6.0" spaceAfter="6.0"/>
38 <paraStyle name="terp_tblheader_Details" fontName="Helvetica-Bold" fontSize="9.0" leading="11" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/>
39 <paraStyle name="terp_default_8" fontName="Helvetica" fontSize="8.0" leading="10" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/>
40 <paraStyle name="terp_default_Bold_8" fontName="Helvetica-Bold" fontSize="8.0" leading="10" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/>
41 <paraStyle name="terp_tblheader_General_Centre" fontName="Helvetica-Bold" fontSize="8.0" leading="10" alignment="CENTER" spaceBefore="6.0" spaceAfter="6.0"/>
42 <paraStyle name="terp_tblheader_General_Right" fontName="Helvetica-Bold" fontSize="8.0" leading="10" alignment="RIGHT" spaceBefore="6.0" spaceAfter="6.0"/>
43 <paraStyle name="terp_tblheader_Details_Centre" fontName="Helvetica-Bold" fontSize="9.0" leading="11" alignment="CENTER" spaceBefore="0.0" spaceAfter="0.0"/>
44 <paraStyle name="terp_tblheader_Details_Right" fontName="Helvetica-Bold" fontSize="9.0" leading="11" alignment="RIGHT" spaceBefore="0.0" spaceAfter="0.0"/>
45 <paraStyle name="terp_default_Right_8" fontName="Helvetica" fontSize="8.0" leading="10" alignment="RIGHT" spaceBefore="0.0" spaceAfter="0.0"/>
46 <paraStyle name="terp_default_Centre_8" fontName="Helvetica" fontSize="8.0" leading="10" alignment="CENTER" spaceBefore="0.0" spaceAfter="0.0"/>
47 <paraStyle name="terp_header_Right" fontName="Helvetica-Bold" fontSize="15.0" leading="19" alignment="LEFT" spaceBefore="12.0" spaceAfter="6.0"/>
48 <paraStyle name="terp_header_Centre" fontName="Helvetica-Bold" fontSize="15.0" leading="19" alignment="CENTER" spaceBefore="12.0" spaceAfter="6.0"/>
49 <paraStyle name="terp_default_address" fontName="Helvetica" fontSize="10.0" leading="13" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/>
50 <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"/>
51 <paraStyle name="terp_default_Bold_9" fontName="Helvetica-Bold" fontSize="9.0" leading="11" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/>
52 <paraStyle name="terp_default_Centre_9" fontName="Helvetica" fontSize="9.0" leading="11" alignment="CENTER" spaceBefore="0.0" spaceAfter="0.0"/>
53 <paraStyle name="terp_default_Right_9" fontName="Helvetica" fontSize="9.0" leading="11" alignment="RIGHT" spaceBefore="0.0" spaceAfter="0.0"/>
54 <paraStyle name="terp_default_2" fontName="Helvetica" fontSize="2.0" leading="3" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/>
55 <images/>
56 </stylesheet>
57 <story>
58 <para style="P3">[[ repeatIn(objects,'o') ]]</para>
59 <section>
60 <para style="P4">
61 <font face="Times-Roman" size="9.0">[[repeatIn(o.packages_ids,'p')]]</font>
62 </para>
63 <para style="P1">[[ p.logo and setTag('para','image',{'width':'300','height':'450'}) or removeParentNode('blockTable') ]][[ p.logo ]]</para>
64 </section>
65 </story>
66</document>
67
068
=== added file 'shipping_api_ups/report/multiple_label_print.sxw'
1Binary 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 differ69Binary 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
=== added file 'shipping_api_ups/report/normalized_oo2rml.xsl'
--- shipping_api_ups/report/normalized_oo2rml.xsl 1970-01-01 00:00:00 +0000
+++ shipping_api_ups/report/normalized_oo2rml.xsl 2011-10-06 16:08:52 +0000
@@ -0,0 +1,696 @@
1<?xml version="1.0" encoding="utf-8"?>
2<xsl:stylesheet
3 version="1.0"
4 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
5 xmlns:fo="http://www.w3.org/1999/XSL/Format"
6 xmlns:office="http://openoffice.org/2000/office"
7 xmlns:style="http://openoffice.org/2000/style"
8 xmlns:text="http://openoffice.org/2000/text"
9 xmlns:table="http://openoffice.org/2000/table"
10 xmlns:draw="http://openoffice.org/2000/drawing"
11 xmlns:xlink="http://www.w3.org/1999/xlink"
12 xmlns:number="http://openoffice.org/2000/datastyle"
13 xmlns:svg="http://www.w3.org/2000/svg"
14 xmlns:chart="http://openoffice.org/2000/chart"
15 xmlns:dr3d="http://openoffice.org/2000/dr3d"
16 xmlns:math="http://www.w3.org/1998/Math/MathML"
17 xmlns:form="http://openoffice.org/2000/form"
18 xmlns:script="http://openoffice.org/2000/script"
19 office:class="text" office:version="1.0"
20 exclude-result-prefixes = "xsl fo office style text table draw xlink number svg chart dr3d math form script">
21
22 <!--TODO's: indent, picture cache (trml2pdf) -->
23
24<xsl:output method="xml" indent="yes" />
25<xsl:strip-space elements="*"/>
26
27<xsl:key name="text_style" match="style:style[@style:family='text']" use="@style:name" />
28<xsl:key name="page_break_before" match="style:style[@style:family='paragraph' and ./style:properties/@fo:break-before='page']" use="@style:name" />
29<xsl:key name="page_break_after" match="style:style[@style:family='paragraph' and ./style:properties/@fo:break-after='page']" use="@style:name" />
30<xsl:key name="table_column_style" match="style:style[@style:family='table-column']" use="@style:name" />
31<xsl:key name="table_cell_style" match="style:style[@style:family='table-cell']" use="@style:name" />
32<xsl:key name="paragraph_style" match="style:style[@style:family='paragraph']" use="@style:name" />
33
34<xsl:template match="office:document-content">
35 <document filename="test.pdf">
36 <xsl:apply-templates select="office:automatic-styles" />
37 <xsl:apply-templates select="office:body" />
38 </document>
39</xsl:template>
40
41<xsl:template name="page_size">
42 <xsl:attribute name="pageSize">
43 <xsl:text>(</xsl:text>
44 <xsl:value-of select="//transferredfromstylesxml/style:page-master[1]/style:properties/@fo:page-width" />
45 <xsl:text>,</xsl:text>
46 <xsl:value-of select="//transferredfromstylesxml/style:page-master[1]/style:properties/@fo:page-height" />
47 <xsl:text>)</xsl:text>
48 </xsl:attribute>
49</xsl:template>
50
51<xsl:template name="fixed_frame">
52 <xsl:for-each select="//draw:text-box">
53 <frame>
54 <xsl:attribute name="id"><xsl:value-of select="./@draw:name" /></xsl:attribute>
55 <xsl:attribute name="x1"><xsl:value-of select="./@svg:x" /></xsl:attribute>
56 <xsl:attribute name="y1">
57 <xsl:value-of
58 select="//transferredfromstylesxml/style:page-master[1]/style:properties/@fo:page-height - ./@svg:y - ./@fo:min-height" />
59 </xsl:attribute>
60 <xsl:attribute name="width">
61 <xsl:value-of select="./@svg:width" />
62 </xsl:attribute>
63 <xsl:attribute name="height">
64 <xsl:value-of select="./@fo:min-height" />
65 </xsl:attribute>
66 </frame>
67 </xsl:for-each>
68</xsl:template>
69
70<xsl:template name="margin_sizes">
71 <xsl:variable name="margin_left" select="//transferredfromstylesxml/style:page-master[1]/style:properties/@fo:margin-left" />
72 <xsl:variable name="margin_right" select="//transferredfromstylesxml/style:page-master[1]/style:properties/@fo:margin-right" />
73 <xsl:variable name="margin_top" select="//transferredfromstylesxml/style:page-master[1]/style:properties/@fo:margin-top" />
74 <xsl:variable name="margin_bottom" select="//transferredfromstylesxml/style:page-master[1]/style:properties/@fo:margin-bottom" />
75 <xsl:variable name="page_width" select="//transferredfromstylesxml/style:page-master[1]/style:properties/@fo:page-width" />
76 <xsl:variable name="page_height" select="//transferredfromstylesxml/style:page-master[1]/style:properties/@fo:page-height" />
77 <xsl:attribute name="x1"><xsl:value-of select="$margin_left" /></xsl:attribute>
78 <xsl:attribute name="y1"><xsl:value-of select="$margin_bottom" /></xsl:attribute>
79 <xsl:attribute name="width"><xsl:value-of select="$page_width - $margin_left - $margin_right"/></xsl:attribute>
80 <xsl:attribute name="height"><xsl:value-of select="$page_height - $margin_bottom - $margin_top"/></xsl:attribute>
81</xsl:template>
82
83<xsl:template name="text_width">
84 <!-- You need this for the workaround to make primitive outlines-->
85 <xsl:variable name="margin_left" select="//transferredfromstylesxml/style:page-master[1]/style:properties/@fo:margin-left" />
86 <xsl:variable name="margin_right" select="//transferredfromstylesxml/style:page-master[1]/style:properties/@fo:margin-right" />
87 <xsl:variable name="page_width" select="//transferredfromstylesxml/style:page-master[1]/style:properties/@fo:page-width" />
88 <xsl:value-of select="$page_width - $margin_left - $margin_right - 18"/>
89</xsl:template>
90
91
92
93<xsl:template match="office:automatic-styles">
94 <!--<template pageSize="(21cm, 29.7cm)" leftMargin="1.0cm" rightMargin="2.0cm" topMargin="1.0cm" bottomMargin="1.0cm" title="Test" author="Martin Simon" allowSplitting="20">-->
95 <template pageSize="(21cm, 29.7cm)" title="Test" author="Martin Simon" allowSplitting="20">
96 <xsl:call-template name="page_size" />
97 <pageTemplate id="first">
98 <xsl:call-template name="fixed_frame" />
99 <frame id="first" x1="2cm" y1="2cm" width="17cm" height="26cm">
100 <xsl:call-template name="margin_sizes" />
101 </frame>
102 </pageTemplate>
103 </template>
104 <stylesheet>
105 <!--A table style to simulate primitive outlines -till the <addOutline> tag is implemented in trml2pdf -->
106 <blockTableStyle id="Standard_Outline">
107 <blockAlignment value="LEFT"/>
108 <blockValign value="TOP"/>
109 </blockTableStyle>
110 <!--use two standard table grid styles like PyOpenOffice "Old Way": with and without a grid-->
111 <!--TODO insert table cell colors here, not within the <td> tag - otherwise
112 it will not work with flowables as cell content-->
113 <xsl:call-template name="make_blocktablestyle" />
114 <initialize>
115 <paraStyle name="all" alignment="justify" />
116 </initialize>
117 <xsl:apply-templates select="style:style" />
118 </stylesheet>
119</xsl:template>
120
121<xsl:template name="make_blocktablestyle">
122 <xsl:for-each select="//table:table">
123 <xsl:variable name="test">
124 <xsl:value-of select="./@table:name" />
125 </xsl:variable>
126 <xsl:if test="not(boolean(count(preceding-sibling::table:table[@table:name=$test])))">
127 <!--Test if this is the first table with this style, nested tables not counted-->
128 <blockTableStyle id="{@table:name}">
129 <xsl:if test=".//draw:image">
130 <blockTopPadding value="0"/>
131 <blockBottomPadding value="0"/>
132 </xsl:if>
133 <blockAlignment value="LEFT" />
134 <blockValign value="TOP" />
135 <xsl:call-template name="make_linestyle" />
136 <xsl:call-template name="make_tablebackground" />
137 </blockTableStyle>
138 </xsl:if>
139 </xsl:for-each>
140</xsl:template>
141
142<xsl:template name="make_linestyle">
143 <xsl:for-each select=".//table:table-row">
144 <xsl:variable name="row" select="position() - 1"/>
145 <xsl:for-each select=".//table:table-cell">
146 <xsl:variable name="col" select="position() - 1"/>
147 <xsl:variable name="linebefore">
148 <xsl:value-of select="key('table_cell_style',@table:style-name)/style:properties/@fo:border-left"/>
149 </xsl:variable>
150 <xsl:if test="not($linebefore='') and not($linebefore='none')">
151 <xsl:variable name="colorname">
152 <xsl:value-of select="substring-after($linebefore,'#')"/>
153 </xsl:variable>
154 <lineStyle kind="LINEBEFORE" colorName="#{$colorname}" start="{$col},{$row}" stop="{$col},-1"/>
155 </xsl:if>
156 <xsl:variable name="lineafter">
157 <xsl:value-of select="key('table_cell_style',@table:style-name)/style:properties/@fo:border-right"/>
158 </xsl:variable>
159 <xsl:if test="not($lineafter='') and not($lineafter='none')">
160 <xsl:variable name="colorname">
161 <xsl:value-of select="substring-after($lineafter,'#')"/>
162 </xsl:variable>
163 <lineStyle kind="LINEAFTER" colorName="#{$colorname}" start="{$col},{$row}" stop="{$col},-1"/>
164 </xsl:if>
165 <xsl:variable name="lineabove">
166 <xsl:value-of select="key('table_cell_style',@table:style-name)/style:properties/@fo:border-top"/>
167 </xsl:variable>
168 <xsl:if test="not($lineabove='') and not($lineabove='none')">
169 <xsl:variable name="colorname">
170 <xsl:value-of select="substring-after($lineabove,'#')"/>
171 </xsl:variable>
172 <lineStyle kind="LINEABOVE" colorName="#{$colorname}" start="{$col},{$row}" stop="{$col},{$row}"/>
173 </xsl:if>
174 <xsl:variable name="linebelow">
175 <xsl:value-of select="key('table_cell_style',@table:style-name)/style:properties/@fo:border-bottom"/>
176 </xsl:variable>
177 <xsl:if test="not($linebelow='') and not($linebelow='none')">
178 <xsl:variable name="colorname">
179 <xsl:value-of select="substring-after($linebelow,'#')"/>
180 </xsl:variable>
181 <lineStyle kind="LINEBELOW" colorName="#{$colorname}" start="{$col},{-1}" stop="{$col},{-1}"/>
182 </xsl:if>
183 <xsl:variable name="grid">
184 <xsl:value-of select="key('table_cell_style',@table:style-name)/style:properties/@fo:border"/>
185 </xsl:variable>
186 <xsl:if test="not($grid='') and not($grid='none')">
187 <xsl:variable name="colorname">
188 <xsl:value-of select="substring-after($grid,'#')"/>
189 </xsl:variable>
190 <!-- Don't use grid because we don't need a line between each rows -->
191 <lineStyle kind="LINEBEFORE" colorName="#{$colorname}" start="{$col},{$row}" stop="{$col},-1"/>
192 <lineStyle kind="LINEAFTER" colorName="#{$colorname}" start="{$col},{$row}" stop="{$col},-1"/>
193 <lineStyle kind="LINEABOVE" colorName="#{$colorname}" start="{$col},{$row}" stop="{$col},{$row}"/>
194 <lineStyle kind="LINEBELOW" colorName="#{$colorname}" start="{$col},{-1}" stop="{$col},{-1}"/>
195 </xsl:if>
196 </xsl:for-each>
197 </xsl:for-each>
198</xsl:template>
199
200<!-- Was needed to simulate bulleted lists:
201<xsl:template match="text:ordered-list|text:unordered-list">
202 <xsl:variable name = "text_width">
203 <xsl:call-template name="text_width" />
204 </xsl:variable>
205 <blockTable style="Standard_Outline" colWidths="18,{$text_width}">
206 <xsl:apply-templates match="text:list-item" />
207</blockTable>
208</xsl:template>
209
210<xsl:template match="text:list-item">
211 <tr>
212 <td><para><font face="Helvetica-Bold" size="10">*</font></para></td>
213 <td>
214 <xsl:apply-templates />
215 </td>
216 </tr>
217</xsl:template>
218
219-->
220
221
222<xsl:template match="office:body">
223 <story>
224 <xsl:apply-templates />
225 <xsl:for-each select="//draw:text-box">
226 <currentFrame>
227 <xsl:attribute name="name">
228 <xsl:value-of select="./@draw:name" />
229 </xsl:attribute>
230 </currentFrame>
231 <xsl:apply-templates>
232 <xsl:with-param name="skip_draw" select="0" />
233 </xsl:apply-templates>
234 <frameEnd />
235 </xsl:for-each>
236 <xsl:for-each select="//text:ordered-list">
237 <para><seqReset id="{./@text:style-name}"/></para>
238 </xsl:for-each>
239 </story>
240</xsl:template>
241
242<xsl:template match="table:table">
243 <blockTable>
244 <xsl:attribute name="colWidths">
245 <xsl:call-template name="make_columns" />
246 </xsl:attribute>
247 <xsl:call-template name="make_tableheaders" />
248 <xsl:attribute name="style">
249 <xsl:value-of select="@table:name" />
250 </xsl:attribute>
251 <xsl:apply-templates />
252 </blockTable>
253</xsl:template>
254
255<xsl:template name="make_tableheaders">
256 <xsl:if test="boolean(count(table:table-header-rows))">
257 <xsl:attribute name="repeatRows">1</xsl:attribute>
258 </xsl:if>
259</xsl:template>
260
261<xsl:template name="make_tablebackground">
262 <xsl:for-each select=".//table:table-row">
263 <!--Be careful when there are table:table-header-rows as
264 parent node of table:table-row -->
265 <xsl:variable name="row" select="position() - 1" />
266 <xsl:for-each select="./table:table-cell">
267 <xsl:variable name="col" select="position() - 1" />
268 <xsl:variable name="background">
269 <xsl:value-of select="key('table_cell_style',@table:style-name)/style:properties/@fo:background-color" />
270 </xsl:variable>
271 <xsl:if test="not($background='') and boolean(key('table_cell_style',@table:style-name)/style:properties/@fo:background-color) and starts-with($background,'#')">
272 <!--only RGB hexcolors are accepted -->
273 <blockBackground colorName="{$background}" start="{$col},{$row}" stop="{$col},-1" />
274 </xsl:if>
275 </xsl:for-each>
276 </xsl:for-each>
277</xsl:template>
278
279<xsl:template name="make_columns">
280 <xsl:variable name="columns" >
281 <xsl:for-each select="table:table-column">
282 <xsl:value-of select="key('table_column_style',@table:style-name)/style:properties/@style:column-width" />
283 <xsl:text>,</xsl:text>
284 </xsl:for-each>
285 </xsl:variable>
286 <xsl:value-of select="substring($columns,1,string-length($columns) - 1)" />
287 <!--strip the last comma-->
288</xsl:template>
289
290<xsl:template match="table:table-row">
291 <tr>
292 <xsl:apply-templates />
293 </tr>
294</xsl:template>
295
296<xsl:template match="table:table-cell">
297 <td>
298 <xsl:apply-templates />
299 </td>
300</xsl:template>
301
302<xsl:template match="text:section">
303 <section>
304 <xsl:apply-templates />
305 </section>
306</xsl:template>
307
308
309<xsl:template match="text:span">
310 <font>
311 <xsl:call-template name="make_fontnames_span" />
312 <xsl:call-template name="make_fontsize_span" />
313 <xsl:apply-templates />
314 </font>
315</xsl:template>
316
317<xsl:template name="make_fontsize_span">
318 <xsl:variable name ="fontsize">
319 <xsl:value-of select="key('text_style',@text:style-name)/style:properties/@fo:font-size" />
320 </xsl:variable>
321 <xsl:if test="not($fontsize='') and boolean(key('text_style',@text:style-name)/style:properties/@fo:font-size)" >
322 <xsl:attribute name="size">
323 <xsl:value-of select="$fontsize" />
324 </xsl:attribute>
325 </xsl:if>
326</xsl:template>
327
328<xsl:template name="make_fontnames_span">
329 <xsl:attribute name="face">
330 <xsl:call-template name="make_fontnames">
331 <xsl:with-param name="fontName" select="key('text_style',@text:style-name)/style:properties/@style:font-name" />
332 <xsl:with-param name="fontWeight" select="key('text_style',@text:style-name)/style:properties/@fo:font-weight" />
333 <xsl:with-param name="fontStyle" select="key('text_style',@text:style-name)/style:properties/@fo:font-style" />
334 </xsl:call-template>
335 </xsl:attribute>
336</xsl:template>
337
338<xsl:template name="make_image">
339 <illustration height="{.//draw:image/@svg:height}" width="{.//draw:image/@svg:width}">
340 <image x="0" y="0" file="{substring-after(.//draw:image/@xlink:href,'#Pictures/')}" height="{.//draw:image/@svg:height}" width="{.//draw:image/@svg:width}" />
341 </illustration>
342</xsl:template>
343
344<xsl:template name="empty_paragraph">
345 <xsl:if test="not(boolean(count(descendant::node())))">
346 <xsl:call-template name="distance_point">
347 <xsl:with-param name="background" select="key('paragraph_style',@text:style-name)/style:properties/@fo:background-color" />
348 </xsl:call-template>
349 </xsl:if>
350</xsl:template>
351
352<xsl:template name="distance_point">
353 <xsl:param name="background" />
354 <xsl:param name="tab_stop"></xsl:param>
355 <xsl:variable name="local_back">
356 <xsl:choose>
357 <xsl:when test="not(boolean($background)) or not(contains($background,'#'))">
358 <!-- Do not accept OO colors like "transparent", only hex-colors -->
359 <xsl:text>white</xsl:text>
360 </xsl:when>
361 <xsl:otherwise>
362 <xsl:value-of select="$background" />
363 </xsl:otherwise>
364 </xsl:choose>
365 </xsl:variable>
366 <font color="{$local_back}">
367 <xsl:text> </xsl:text>
368 <xsl:if test="boolean($tab_stop)">
369 <!-- simulate a tabstop with white/background-color points -->
370 <xsl:text>.........</xsl:text>
371 </xsl:if>
372 </font>
373</xsl:template>
374
375<xsl:template match="text:ordered-list">
376 <xsl:apply-templates />
377
378 <!-- Reset the counter. seqreset is not a trml2pdf tag, but a Platypus Intra Paragraph Markup,
379 so it needs a dummy paragraph to enclose it -->
380</xsl:template>
381
382<xsl:template name="make_listitem">
383 <xsl:if test="(name(..)='text:list-item')">
384 <xsl:attribute name="leftIndent">15</xsl:attribute>
385 <xsl:attribute name="bulletIndent">0</xsl:attribute>
386 <xsl:choose>
387 <xsl:when test="(name(../..)='text:unordered-list')">
388 <xsl:variable name="fontsize">
389 <xsl:value-of select="number(key('paragraph_style',@text:style-name)/style:properties/@fo:font-size)" />
390 </xsl:variable>
391 <xsl:choose>
392 <xsl:when test="$fontsize='NaN'">
393 <!-- you should exclude non-numerical values for bulletFontSize. <== Sometimes the preprocessing went wrong.-->
394 <!--use a default bullet font size-->
395 <xsl:attribute name="bulletFontSize">6</xsl:attribute>
396 </xsl:when>
397 <xsl:otherwise>
398 <xsl:attribute name="bulletFontSize"><xsl:value-of select="floor(($fontsize div 2) + 1)" /></xsl:attribute>
399 </xsl:otherwise>
400 </xsl:choose>
401 <xsl:attribute name="bulletFontName">ZapfDingbats</xsl:attribute>
402 <xsl:attribute name="bulletText">l</xsl:attribute>
403 </xsl:when>
404 <xsl:otherwise>
405 <!-- Generate the numbers for an ordered list -->
406 <xsl:variable name="size">
407 <xsl:value-of select="key('paragraph_style',@text:style-name)/style:properties/@fo:font-size" />
408 </xsl:variable>
409 <!-- For ordered lists we use the bullet tag from Platypus Intra Paragraph Markup -->
410 <bullet>
411 <xsl:if test="not($size='') and boolean(key('paragraph_style',@text:style-name)/style:properties/@fo:font-size)">
412 <xsl:attribute name="size">
413 <!-- adapt the fontsize to the fontsize of the current paragraph -->
414 <xsl:value-of select="$size" />
415 </xsl:attribute>
416 </xsl:if>
417 <seq id="{../../@text:style-name}"/>.</bullet>
418
419 </xsl:otherwise>
420 </xsl:choose>
421 </xsl:if>
422</xsl:template>
423
424<xsl:template match="text:drop-down">
425 <xsl:value-of select="text:label[2]/@text:value" />
426</xsl:template>
427
428
429<xsl:template match="text:p|text:h">
430 <xsl:param name="skip_draw" select="1" />
431 <xsl:if test="boolean(key('page_break_before',@text:style-name))" >
432 <pageBreak />
433 </xsl:if>
434 <xsl:choose>
435 <xsl:when test="boolean(.//draw:image)">
436 <xsl:call-template name="make_image" />
437 </xsl:when>
438 <xsl:when test="boolean(name(..) = 'draw:text-box') and boolean($skip_draw)">
439 </xsl:when>
440 <xsl:otherwise>
441 <para>
442 <xsl:attribute name="style">
443 <xsl:value-of select="@text:style-name" />
444 </xsl:attribute>
445 <xsl:call-template name="make_listitem" />
446 <xsl:apply-templates />
447 <xsl:call-template name="empty_paragraph" />
448 </para>
449 </xsl:otherwise>
450 </xsl:choose>
451 <xsl:if test="boolean(key('page_break_after',@text:style-name))" >
452 <pageBreak />
453 </xsl:if>
454</xsl:template>
455
456<xsl:template match="text:p/text:tab-stop">
457 <!-- simulate a tabstop -->
458 <xsl:call-template name="distance_point">
459 <xsl:with-param name="background" select="key('paragraph_style',@text:style-name)/style:properties/@fo:background-color" />
460 <xsl:with-param name="tab_stop">yes</xsl:with-param>
461 </xsl:call-template>
462</xsl:template>
463
464<!-- experimental - switched off
465<xsl:template match="text:h">
466 <para>
467 <xsl:attribute name="style">
468 <xsl:value-of select="@text:style-name" />
469 </xsl:attribute>
470 <xsl:call-template name="make_number" />
471 <xsl:apply-templates />
472 <xsl:call-template name="empty_paragraph" />
473 </para>
474</xsl:template>
475
476<xsl:template name="make_number">
477 <xsl:choose>
478 <xsl:when test="@text:level='1'">
479 <xsl:number format="1. " />
480 </xsl:when>
481 <xsl:when test="@text:level='2'">
482 <xsl:number count="text:h[@text:level='1']|text:h[text:level='2']" level="any" format="1.1." />
483 </xsl:when>
484 </xsl:choose>
485</xsl:template>
486
487-->
488
489<xsl:template match="style:style[@style:family='paragraph']">
490 <paraStyle>
491 <xsl:attribute name="name">
492 <xsl:value-of select="@style:name" />
493 </xsl:attribute>
494 <xsl:call-template name="make_indent_paragraph" />
495 <xsl:call-template name="make_fontnames_paragraph" />
496 <xsl:call-template name="make_fontsize" />
497 <!--<xsl:call-template name="make_parent" /> not necessary -
498 parent styles processed by PyOpenOffice -->
499 <xsl:call-template name="make_alignment" />
500 <xsl:call-template name="make_background" />
501 <xsl:call-template name="make_space_beforeafter" />
502 <xsl:call-template name="make_fontcolor" />
503 </paraStyle>
504</xsl:template>
505
506<xsl:template name="make_indent_paragraph">
507 <xsl:variable name="right_indent"><xsl:value-of select="style:properties/@fo:margin-right" /></xsl:variable>
508 <xsl:variable name="left_indent"><xsl:value-of select="style:properties/@fo:margin-left" /></xsl:variable>
509 <xsl:if test="not($right_indent='') and boolean(style:properties/@fo:margin-right)">
510 <xsl:attribute name="rightIndent">
511 <xsl:value-of select="$right_indent" />
512 </xsl:attribute>
513 </xsl:if>
514 <xsl:if test="not($left_indent='') and boolean(style:properties/@fo:margin-left)">
515 <xsl:attribute name="leftIndent">
516 <xsl:value-of select="$left_indent" />
517 </xsl:attribute>
518 </xsl:if>
519</xsl:template>
520
521<xsl:template name="make_background">
522 <xsl:variable name="background">
523 <xsl:value-of select="style:properties/@fo:background-color" />
524 </xsl:variable>
525 <xsl:if test="not($background='') and boolean(style:properties/@fo:background-color) and starts-with($background,'#')" >
526 <xsl:attribute name="backColor">
527 <xsl:value-of select="$background" />
528 </xsl:attribute>
529 </xsl:if>
530</xsl:template>
531
532<xsl:template name="make_space_beforeafter">
533 <xsl:variable name="before">
534 <xsl:value-of select="style:properties/@fo:margin-top" />
535 </xsl:variable>
536 <xsl:variable name="after">
537 <xsl:value-of select="style:properties/@fo:margin-bottom" />
538 </xsl:variable>
539 <xsl:if test="not($before='') and boolean(style:properties/@fo:margin-top)" >
540 <xsl:attribute name="spaceBefore">
541 <xsl:value-of select="$before" />
542 </xsl:attribute>
543 </xsl:if>
544 <xsl:if test="not($after='') and boolean(style:properties/@fo:margin-bottom)" >
545 <xsl:attribute name="spaceAfter">
546 <xsl:value-of select="$after" />
547 </xsl:attribute>
548 </xsl:if>
549</xsl:template>
550
551<xsl:template name="make_fontsize">
552 <xsl:variable name="fontSize">
553 <xsl:value-of select="style:properties/@fo:font-size" />
554 </xsl:variable>
555 <xsl:if test="not($fontSize='') and boolean(style:properties/@fo:font-size)">
556 <xsl:attribute name="fontSize">
557 <xsl:value-of select="$fontSize" />
558 </xsl:attribute>
559 <xsl:attribute name="leading">
560 <xsl:value-of select="$fontSize + floor($fontSize div 5) + 1" />
561 <!--use a standard leading related to the font size -->
562 </xsl:attribute>
563 </xsl:if>
564</xsl:template>
565
566<!--this template is not needed anymore for "normalized" sxw files -->
567<xsl:template name="make_parent">
568 <xsl:variable name="parent">
569 <xsl:value-of select="@style:parent-style-name" />
570 </xsl:variable>
571 <xsl:if test="not($parent='') and boolean(@style:parent-style-name)">
572 <xsl:attribute name="parent">
573 <xsl:value-of select="$parent" />
574 </xsl:attribute>
575 </xsl:if>
576</xsl:template>
577
578<xsl:template name="make_alignment">
579 <xsl:variable name="alignment">
580 <xsl:value-of select="style:properties/@fo:text-align" />
581 </xsl:variable>
582 <xsl:if test="not($alignment='') and boolean(style:properties/@fo:text-align)">
583 <xsl:choose>
584 <xsl:when test="$alignment='start'">
585 <xsl:attribute name="alignment">LEFT</xsl:attribute>
586 </xsl:when>
587 <xsl:when test="$alignment='center'">
588 <xsl:attribute name="alignment">CENTER</xsl:attribute>
589 </xsl:when>
590 <xsl:when test="$alignment='end'">
591 <xsl:attribute name="alignment">RIGHT</xsl:attribute>
592 </xsl:when>
593 <xsl:when test="$alignment='justify'">
594 <xsl:attribute name="alignment">JUSTIFY</xsl:attribute>
595 </xsl:when>
596 </xsl:choose>
597 </xsl:if>
598</xsl:template>
599
600<xsl:template name="make_fontnames_paragraph">
601 <xsl:attribute name="fontName">
602 <xsl:call-template name="make_fontnames">
603 <xsl:with-param name="fontName" select="style:properties/@style:font-name" />
604 <xsl:with-param name="fontWeight" select="style:properties/@fo:font-weight" />
605 <xsl:with-param name="fontStyle" select="style:properties/@fo:font-style" />
606 </xsl:call-template>
607 </xsl:attribute>
608</xsl:template>
609
610<xsl:template name="make_fontnames">
611 <!--much too verbose, needs improvement-->
612<xsl:param name="fontName" />
613<xsl:param name="fontWeight" />
614<xsl:param name="fontStyle" />
615<xsl:choose>
616<xsl:when test="not($fontName='') and boolean($fontName)">
617 <xsl:choose>
618 <xsl:when test="contains($fontName,'Courier')">
619 <xsl:choose>
620 <xsl:when test="($fontWeight='bold') and ($fontStyle='italic')">
621 <xsl:text>Courier-BoldOblique</xsl:text>
622 </xsl:when>
623 <xsl:when test="($fontWeight='bold') and not ($fontStyle='italic')">
624 <xsl:text>Courier-Bold</xsl:text>
625 </xsl:when>
626 <xsl:when test="not($fontWeight='bold') and ($fontStyle='italic')">
627 <xsl:text>Courier-Oblique</xsl:text>
628 </xsl:when>
629 <xsl:otherwise>
630 <xsl:text>Courier</xsl:text>
631 </xsl:otherwise>
632 </xsl:choose>
633 </xsl:when>
634 <xsl:when test="contains($fontName,'Helvetica') or contains($fontName,'Arial') or contains($fontName,'Sans')">
635 <xsl:choose>
636 <xsl:when test="($fontWeight='bold') and ($fontStyle='italic')">
637 <xsl:text>Helvetica-BoldOblique</xsl:text>
638 </xsl:when>
639 <xsl:when test="($fontWeight='bold') and not ($fontStyle='italic')">
640 <xsl:text>Helvetica-Bold</xsl:text>
641 </xsl:when>
642 <xsl:when test="not($fontWeight='bold') and ($fontStyle='italic')">
643 <xsl:text>Helvetica-Oblique</xsl:text>
644 </xsl:when>
645 <xsl:otherwise>
646 <xsl:text>Helvetica</xsl:text>
647 </xsl:otherwise>
648 </xsl:choose>
649 </xsl:when>
650 <xsl:otherwise>
651 <xsl:choose>
652 <xsl:when test="($fontWeight='bold') and ($fontStyle='italic')">
653 <xsl:text>Times-BoldItalic</xsl:text>
654 </xsl:when>
655 <xsl:when test="($fontWeight='bold') and not ($fontStyle='italic')">
656 <xsl:text>Times-Bold</xsl:text>
657 </xsl:when>
658 <xsl:when test="not($fontWeight='bold') and ($fontStyle='italic')">
659 <xsl:text>Times-Italic</xsl:text>
660 </xsl:when>
661 <xsl:otherwise>
662 <xsl:text>Times-Roman</xsl:text>
663 </xsl:otherwise>
664 </xsl:choose>
665 </xsl:otherwise>
666 </xsl:choose>
667</xsl:when>
668<xsl:otherwise>
669 <!--Use this as default -->
670 <xsl:text>Times-Roman</xsl:text>
671</xsl:otherwise>
672</xsl:choose>
673</xsl:template>
674<xsl:template name="make_fontcolor">
675 <xsl:variable name="textColor">
676 <xsl:value-of select="style:properties/@fo:color"/>
677 </xsl:variable>
678 <xsl:if test="not($textColor='') and boolean(style:properties/@fo:color)">
679 <xsl:attribute name="textColor">
680 <xsl:value-of select="$textColor" />
681 </xsl:attribute>
682 </xsl:if>
683</xsl:template>
684
685<!--
686This stylesheet is part of:
687PyOpenOffice Version 0.4
688Copyright (C) 2005: Martin Simon
689Homepage: www.bezirksreiter.de
690
691GNU LESSER GENERAL PUBLIC LICENSE Version 2.1, February 1999
692-->
693
694</xsl:stylesheet>
695
696
0697
=== added file 'shipping_api_ups/report/summary_report.py'
--- shipping_api_ups/report/summary_report.py 1970-01-01 00:00:00 +0000
+++ shipping_api_ups/report/summary_report.py 2011-10-06 16:08:52 +0000
@@ -0,0 +1,55 @@
1# -*- coding: utf-8 -*-
2##############################################################################
3#
4# OpenERP, Open Source Management Solution
5# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
6#
7# This program is free software: you can redistribute it and/or modify
8# it under the terms of the GNU Affero General Public License as
9# published by the Free Software Foundation, either version 3 of the
10# License, or (at your option) any later version.
11#
12# This program is distributed in the hope that it will be useful,
13# but WITHOUT ANY WARRANTY; without even the implied warranty of
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15# GNU Affero General Public License for more details.
16#
17# You should have received a copy of the GNU Affero General Public License
18# along with this program. If not, see <http://www.gnu.org/licenses/>.
19#
20##############################################################################
21
22import time
23from report import report_sxw
24import pooler
25
26
27class summary_report_print(report_sxw.rml_parse):
28 def __init__(self, cr, uid, name, context):
29 super(summary_report_print, self).__init__(cr, uid, name, context)
30 db_pool = pooler.get_pool(self.cr.dbname)
31 self.localcontext.update({
32 'time': time,
33 'get_total':self.get_total,
34 'get_items':self.get_items,
35 })
36 def get_total(self):
37 ship_ids=pooler.get_pool(self.cr.dbname).get('shipping.move').search(self.cr,self.uid,[('state','=','ready_pick')])
38 return str(len(ship_ids))
39 def get_items(self):
40 ret = {}
41 ship_ids=pooler.get_pool(self.cr.dbname).get('shipping.move').search(self.cr,self.uid,[('state','=','ready_pick')])
42 if ship_ids:
43 for ship_id in pooler.get_pool(self.cr.dbname).get('shipping.move').browse(self.cr,self.uid,ship_ids):
44 key = ship_id.service and ship_id.service.description or ''
45 ret[key] = 1 + ret.get(key,0)
46 return ret.items()
47
48
49report_sxw.report_sxw(
50 'report.summary_report_print',
51 'shipping.move',
52 'addons/shipping_api/report/summary_report.rml',
53 parser=summary_report_print
54)
55
056
=== added file 'shipping_api_ups/report/summary_report.rml'
--- shipping_api_ups/report/summary_report.rml 1970-01-01 00:00:00 +0000
+++ shipping_api_ups/report/summary_report.rml 2011-10-06 16:08:52 +0000
@@ -0,0 +1,97 @@
1<?xml version="1.0"?>
2<document filename="test.pdf">
3 <template pageSize="(595.0,842.0)" title="Test" author="Martin Simon" allowSplitting="20">
4 <pageTemplate id="first">
5 <frame id="first" x1="55.0" y1="0.0" width="495" height="786"/>
6 </pageTemplate>
7 </template>
8 <stylesheet>
9 <blockTableStyle id="Standard_Outline">
10 <blockAlignment value="LEFT"/>
11 <blockValign value="TOP"/>
12 </blockTableStyle>
13 <blockTableStyle id="Table2">
14 <blockAlignment value="LEFT"/>
15 <blockValign value="TOP"/>
16 <lineStyle kind="LINEBEFORE" colorName="#000000" start="0,0" stop="0,-1"/>
17 <lineStyle kind="LINEABOVE" colorName="#000000" start="0,0" stop="0,0"/>
18 <lineStyle kind="LINEBELOW" colorName="#000000" start="0,-1" stop="0,-1"/>
19 <lineStyle kind="LINEBEFORE" colorName="#000000" start="1,0" stop="1,-1"/>
20 <lineStyle kind="LINEAFTER" colorName="#000000" start="1,0" stop="1,-1"/>
21 <lineStyle kind="LINEABOVE" colorName="#000000" start="1,0" stop="1,0"/>
22 <lineStyle kind="LINEBELOW" colorName="#000000" start="1,-1" stop="1,-1"/>
23 </blockTableStyle>
24 <blockTableStyle id="Table4">
25 <blockAlignment value="LEFT"/>
26 <blockValign value="TOP"/>
27 <lineStyle kind="LINEBEFORE" colorName="#000000" start="0,0" stop="0,-1"/>
28 <lineStyle kind="LINEABOVE" colorName="#000000" start="0,0" stop="0,0"/>
29 <lineStyle kind="LINEBELOW" colorName="#000000" start="0,-1" stop="0,-1"/>
30 <lineStyle kind="LINEBEFORE" colorName="#000000" start="1,0" stop="1,-1"/>
31 <lineStyle kind="LINEAFTER" colorName="#000000" start="1,0" stop="1,-1"/>
32 <lineStyle kind="LINEABOVE" colorName="#000000" start="1,0" stop="1,0"/>
33 <lineStyle kind="LINEBELOW" colorName="#000000" start="1,-1" stop="1,-1"/>
34 </blockTableStyle>
35 <initialize>
36 <paraStyle name="all" alignment="justify"/>
37 </initialize>
38 <paraStyle name="P1" rightIndent="22.0" leftIndent="20.0" fontName="Helvetica-Bold" fontSize="14.0" leading="17" alignment="CENTER"/>
39 <paraStyle name="P2" rightIndent="22.0" leftIndent="20.0" fontName="Helvetica-Bold" fontSize="15.0" leading="19"/>
40 <paraStyle name="P3" rightIndent="22.0" leftIndent="20.0" fontName="Helvetica" fontSize="11.0" leading="14"/>
41 <paraStyle name="P4" fontName="Helvetica" fontSize="15.0" leading="19"/>
42 <paraStyle name="P5" rightIndent="22.0" leftIndent="0.0" fontName="Helvetica" fontSize="11.0" leading="14"/>
43 <paraStyle name="P6" rightIndent="22.0" leftIndent="0.0" fontName="Helvetica-Bold" fontSize="11.0" leading="14"/>
44 <paraStyle name="P7" rightIndent="22.0" leftIndent="0.0" fontName="Helvetica-Bold" fontSize="15.0" leading="19"/>
45 <paraStyle name="P8" rightIndent="22.0" leftIndent="0.0" fontName="Helvetica"/>
46 <paraStyle name="Standard" fontName="Helvetica"/>
47 <paraStyle name="Heading" fontName="Helvetica" fontSize="14.0" leading="17" spaceBefore="12.0" spaceAfter="6.0"/>
48 <paraStyle name="Text body" fontName="Helvetica" spaceBefore="0.0" spaceAfter="6.0"/>
49 <paraStyle name="List" fontName="Helvetica" spaceBefore="0.0" spaceAfter="6.0"/>
50 <paraStyle name="Caption" fontName="Helvetica" fontSize="12.0" leading="15" spaceBefore="6.0" spaceAfter="6.0"/>
51 <paraStyle name="Index" fontName="Helvetica"/>
52 <paraStyle name="Table Contents" fontName="Helvetica"/>
53 <paraStyle name="Table Heading" fontName="Helvetica" alignment="CENTER"/>
54 <images/>
55 </stylesheet>
56 <story>
57 <para style="P1">Shipping Summary Report</para>
58 <para style="P3">
59 <font color="white"> </font>
60 </para>
61 <para style="P5">
62 <font color="white"> </font>
63 </para>
64 <para style="P6">Date : [[time.strftime("%b %d, %Y")]]</para>
65 <para style="P6">Total number of packages : [[get_total()]]</para>
66 <para style="P7">
67 <font color="white"> </font>
68 </para>
69 <blockTable colWidths="248.0,248.0" style="Table2">
70 <tr>
71 <td>
72 <para style="P2">Shipping Method</para>
73 </td>
74 <td>
75 <para style="P2">Count</para>
76 </td>
77 </tr>
78 </blockTable>
79 <blockTable colWidths="248.0,248.0" style="Table4">
80 <tr>
81 <td>
82 <para style="P4">[[not get_items() and removeParentNode('blockTable')]][[repeatIn(get_items(),'p')]][[ p[0] ]]</para>
83 </td>
84 <td>
85 <para style="P4">[[ p[1] ]]</para>
86 </td>
87 </tr>
88 </blockTable>
89 <para style="P7">
90 <font color="white"> </font>
91 </para>
92 <para style="P8">
93 <font color="white"> </font>
94 </para>
95 </story>
96</document>
97
098
=== added file 'shipping_api_ups/report/summary_report.sxw'
1Binary 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 differ99Binary 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
=== added file 'shipping_api_ups/report/tiny_sxw2rml.py'
--- shipping_api_ups/report/tiny_sxw2rml.py 1970-01-01 00:00:00 +0000
+++ shipping_api_ups/report/tiny_sxw2rml.py 2011-10-06 16:08:52 +0000
@@ -0,0 +1,377 @@
1#!/usr/bin/python
2# -*- encoding: utf-8 -*-
3##############################################################################
4#
5# Copyright (c):
6#
7# 2005 pyopenoffice.py Martin Simon (http://www.bezirksreiter.de)
8# 2005 Fabien Pinckaers, TINY SPRL. (http://tiny.be)
9#
10# WARNING: This program as such is intended to be used by professional
11# programmers who take the whole responsability of assessing all potential
12# consequences resulting from its eventual inadequacies and bugs
13# End users who are looking for a ready-to-use solution with commercial
14# garantees and support are strongly adviced to contact a Free Software
15# Service Company
16#
17# This program is Free Software; you can redistribute it and/or
18# modify it under the terms of the GNU General Public License
19# as published by the Free Software Foundation; either version 2
20# of the License, or (at your option) any later version.
21#
22# This program is distributed in the hope that it will be useful,
23# but WITHOUT ANY WARRANTY; without even the implied warranty of
24# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25# GNU General Public License for more details.
26#
27# You should have received a copy of the GNU General Public License
28# along with this program; if not, write to the Free Software
29# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
30#
31##############################################################################
32
33"""
34Tiny SXW2RML - The Open ERP's report engine
35
36Tiny SXW2RMLis part of the Tiny report project.
37Tiny Report is a module that allows you to render high quality PDF document
38from an OpenOffice template (.sxw) and any relationnal database.
39
40The whole source code is distributed under the terms of the
41GNU Public Licence.
42
43(c) 2005 pyopenoffice.py Martin Simon (http://www.bezirksreiter.de)
44(c) 2005-TODAY, Fabien Pinckaers - Tiny sprl
45"""
46__version__ = '0.9'
47
48
49import re
50import string
51import os
52import zipfile
53import xml.dom.minidom
54from reportlab.lib.units import toLength
55import base64
56
57class DomApiGeneral:
58 """General DOM API utilities."""
59 def __init__(self,content_string="",file=""):
60 self.content_string = content_string
61 self.re_digits = re.compile(r"(.*?\d)(pt|cm|mm|inch|in)")
62
63 def _unitTuple(self,string):
64 """Split values and units to a tuple."""
65 temp = self.re_digits.findall(string)
66 if not temp:
67 return (string,"")
68 else:
69 return (temp[0])
70
71 def stringPercentToFloat(self,string):
72 temp = string.replace("""%""","")
73 return float(temp)/100
74
75 def findChildrenByName(self,parent,name,attr_dict={}):
76 """Helper functions. Does not work recursively.
77 Optional: also test for certain attribute/value pairs."""
78 children = []
79 for c in parent.childNodes:
80 if c.nodeType == c.ELEMENT_NODE and c.nodeName == name:
81 children.append(c)
82 if attr_dict == {}:
83 return children
84 else:
85 return self._selectForAttributes(nodelist=children,attr_dict=attr_dict)
86
87 def _selectForAttributes(self,nodelist,attr_dict):
88 "Helper function."""
89 selected_nodes = []
90 for n in nodelist:
91 check = 1
92 for a in attr_dict.keys():
93 if n.getAttribute(a) != attr_dict[a]:
94 # at least one incorrect attribute value?
95 check = 0
96 if check:
97 selected_nodes.append(n)
98 return selected_nodes
99
100 def _stringToTuple(self,s):
101 """Helper function."""
102 try:
103 temp = string.split(s,",")
104 return int(temp[0]),int(temp[1])
105 except:
106 return None
107
108 def _tupleToString(self,t):
109 try:
110 return self.openOfficeStringUtf8("%s,%s" % (t[0],t[1]))
111 except:
112 return None
113
114 def _lengthToFloat(self,value):
115 v = value
116 if not self.re_digits.search(v):
117 return v
118 try:
119 if v[-4:] == "inch":
120 # OO files use "inch" instead of "in" in Reportlab units
121 v = v[:-2]
122 except:
123 pass
124 try:
125 c = round(toLength(v))
126 return c
127 except:
128 return v
129
130 def openOfficeStringUtf8(self,string):
131 if type(string) == unicode:
132 return string.encode("utf-8")
133 tempstring = unicode(string,"cp1252").encode("utf-8")
134 return tempstring
135
136class DomApi(DomApiGeneral):
137 """This class provides a DOM-API for XML-Files from an SXW-Archive."""
138 def __init__(self,xml_content,xml_styles):
139 DomApiGeneral.__init__(self)
140 self.content_dom = xml.dom.minidom.parseString(xml_content)
141 self.styles_dom = xml.dom.minidom.parseString(xml_styles)
142 body = self.content_dom.getElementsByTagName("office:body")
143 self.body = body and body[0]
144
145 # TODO:
146 self.style_dict = {}
147 self.style_properties_dict = {}
148
149 # ******** always use the following order:
150 self.buildStyleDict()
151 self.buildStylePropertiesDict()
152 if self.styles_dom.getElementsByTagName("style:page-master").__len__()<>0:
153 self.page_master = self.styles_dom.getElementsByTagName("style:page-master")[0]
154 if self.styles_dom.getElementsByTagName("style:page-layout").__len__()<>0 :
155 self.page_master = self.styles_dom.getElementsByTagName("style:page-layout")[0]
156 self.document = self.content_dom.getElementsByTagName("office:document-content")[0]
157
158 def buildStylePropertiesDict(self):
159 for s in self.style_dict.keys():
160 self.style_properties_dict[s] = self.getStylePropertiesDict(s)
161
162 def updateWithPercents(self,dict,updatedict):
163 """Sometimes you find values like "115%" in the style hierarchy."""
164 if not updatedict:
165 # no style hierarchies for this style? =>
166 return
167 new_updatedict = copy.copy(updatedict)
168 for u in new_updatedict.keys():
169 try:
170 if new_updatedict[u].find("""%""") != -1 and dict.has_key(u):
171 number = float(self.re_digits.search(dict[u]).group(1))
172 unit = self.re_digits.search(dict[u]).group(2)
173 new_number = self.stringPercentToFloat(new_updatedict[u]) * number
174 if unit == "pt":
175 new_number = int(new_number)
176 # no floats allowed for "pt"
177 # OOo just takes the int, does not round (try it out!)
178 new_updatedict[u] = "%s%s" % (new_number,unit)
179 else:
180 dict[u] = new_updatedict[u]
181 except:
182 dict[u] = new_updatedict[u]
183 dict.update(new_updatedict)
184
185 def normalizeStyleProperties(self):
186 """Transfer all style:style-properties attributes from the
187 self.style_properties_hierarchical dict to the automatic-styles
188 from content.xml. Use this function to preprocess content.xml for
189 XSLT transformations etc.Do not try to implement this function
190 with XSlT - believe me, it's a terrible task..."""
191 styles_styles = self.styles_dom.getElementsByTagName("style:style")
192 automatic_styles = self.content_dom.getElementsByTagName("office:automatic-styles")[0]
193 for s in styles_styles:
194 automatic_styles.appendChild(s.cloneNode(deep=1))
195 content_styles = self.content_dom.getElementsByTagName("style:style")
196 # these are the content_styles with styles_styles added!!!
197 for s in content_styles:
198 c = self.findChildrenByName(s,"style:properties")
199 if c == []:
200 # some derived automatic styles do not have "style:properties":
201 temp = self.content_dom.createElement("style:properties")
202 s.appendChild(temp)
203 c = self.findChildrenByName(s,"style:properties")
204 c = c[0]
205 dict = self.style_properties_dict[(s.getAttribute("style:name")).encode("utf-8")] or {}
206 for attribute in dict.keys():
207 c.setAttribute(self.openOfficeStringUtf8(attribute),self.openOfficeStringUtf8(dict[attribute]))
208
209 def transferStylesXml(self):
210 """Transfer certain sub-trees from styles.xml to the normalized content.xml
211 (see above). It is not necessary to do this - for example - with paragraph styles.
212 the "normalized" style properties contain all information needed for
213 further processing."""
214 # TODO: What about table styles etc.?
215 outline_styles = self.styles_dom.getElementsByTagName("text:outline-style")
216 t = self.content_dom.createElement("transferredfromstylesxml")
217 self.document.insertBefore(t,self.body)
218 t_new = self.body.previousSibling
219 try:
220 page_master = self.page_master
221 t_new.appendChild(page_master.cloneNode(deep=1))
222 t_new.appendChild(outline_styles[0].cloneNode(deep=1))
223 except:
224 pass
225
226 def normalizeLength(self):
227 """Normalize all lengthes to floats (i.e: 1 inch = 72).
228 Always use this after "normalizeContent" and "transferStyles"!"""
229 # TODO: The complex attributes of table cell styles are not transferred yet.
230 #all_styles = self.content_dom.getElementsByTagName("style:properties")
231 #all_styles += self.content_dom.getElementsByTagName("draw:image")
232 all_styles = self.content_dom.getElementsByTagName("*")
233 for s in all_styles:
234 for x in s._attrs.keys():
235 v = s.getAttribute(x)
236 s.setAttribute(x,"%s" % self._lengthToFloat(v))
237 # convert float to string first!
238
239 def normalizeTableColumns(self):
240 """Handle this strange table:number-columns-repeated attribute."""
241 columns = self.content_dom.getElementsByTagName("table:table-column")
242 for c in columns:
243 if c.hasAttribute("table:number-columns-repeated"):
244 number = int(c.getAttribute("table:number-columns-repeated"))
245 c.removeAttribute("table:number-columns-repeated")
246 for i in range(number-1):
247 (c.parentNode).insertBefore(c.cloneNode(deep=1),c)
248
249 def buildStyleDict(self):
250 """Store all style:style-nodes from content.xml and styles.xml in self.style_dict.
251 Caution: in this dict the nodes from two dom apis are merged!"""
252 for st in (self.styles_dom,self.content_dom):
253 for s in st.getElementsByTagName("style:style"):
254 name = s.getAttribute("style:name").encode("utf-8")
255 self.style_dict[name] = s
256 return True
257
258 def toxml(self):
259 return self.content_dom.toxml(encoding="utf-8")
260
261 def getStylePropertiesDict(self,style_name):
262 res = {}
263
264 if self.style_dict[style_name].hasAttribute("style:parent-style-name"):
265 parent = self.style_dict[style_name].getAttribute("style:parent-style-name").encode("utf-8")
266 res = self.getStylePropertiesDict(parent)
267
268 childs = self.style_dict[style_name].childNodes
269 for c in childs:
270 if c.nodeType == c.ELEMENT_NODE and c.nodeName.find("properties")>0 :
271 for attr in c._attrs.keys():
272 res[attr] = c.getAttribute(attr).encode("utf-8")
273 return res
274
275class PyOpenOffice(object):
276 """This is the main class which provides all functionality."""
277 def __init__(self, path='.', save_pict=False):
278 self.path = path
279 self.save_pict = save_pict
280 self.images = {}
281
282 def oo_read(self,fname):
283 z = zipfile.ZipFile(fname,"r")
284 content = z.read('content.xml')
285 style = z.read('styles.xml')
286 all = z.namelist()
287 for a in all:
288 if a[:9]=='Pictures/' and len(a)>10:
289 pic_content = z.read(a)
290 self.images[a[9:]] = pic_content
291 if self.save_pict:
292 f=open(os.path.join(self.path, os.path.basename(a)),"wb")
293 f.write(pic_content)
294 f.close()
295 z.close()
296 return content,style
297
298 def oo_replace(self,content):
299 regex = [
300 (r"<para[^>]*/>", ""),
301 #(r"<text:ordered-list.*?>(.*?)</text:ordered-list>", "$1"),
302 #(r"<text:unordered-list.*?>(.*?)</text:unordered-list>", "$1"),
303 (r"<para(.*)>(.*?)<text:line-break[^>]*/>", "<para$1>$2</para><para$1>"),
304 ]
305 for key,val in regex:
306 content = re.sub(key, val, content)
307 return content
308
309 def unpackNormalize(self,sourcefile):
310 c,s = self.oo_read(sourcefile)
311 c = self.oo_replace(c)
312 dom = DomApi(c,s)
313 dom.normalizeStyleProperties()
314 dom.transferStylesXml()
315 dom.normalizeLength()
316 dom.normalizeTableColumns()
317 new_c = dom.toxml()
318 return new_c
319
320def sxw2rml(sxw_file, xsl, output='.', save_pict=False):
321 from lxml import etree
322 from StringIO import StringIO
323
324 tool = PyOpenOffice(output, save_pict = save_pict)
325 res = tool.unpackNormalize(sxw_file)
326
327 f = StringIO(xsl)
328 styledoc = etree.parse(f)
329 style = etree.XSLT(styledoc)
330
331 f = StringIO(res)
332 doc = etree.parse(f)
333 result = style(doc)
334 root = etree.XPathEvaluator(result)("/document/stylesheet")
335
336 if root:
337 root=root[0]
338 images = etree.Element("images")
339 for img in tool.images:
340 node = etree.Element('image', name=img)
341 node.text = base64.encodestring(tool.images[img])
342 images.append(node)
343 root.append(images)
344
345 try:
346 xml = str(result)
347 return xml
348 except:
349 return result
350
351if __name__ == "__main__":
352 import optparse
353 parser = optparse.OptionParser(
354 version="Tiny Report v%s" % __version__,
355 usage = 'tiny_sxw2rml.py [options] file.sxw')
356 parser.add_option("-v", "--verbose", default=False, dest="verbose", help="enable basic debugging")
357 parser.add_option("-o", "--output", dest="output", default='.', help="directory of image output")
358 (opt, args) = parser.parse_args()
359 if len(args) != 1:
360 parser.error("incorrect number of arguments")
361
362 import sys
363 import StringIO
364
365 fname = sys.argv[1]
366 f = fname
367 xsl_file = 'normalized_oo2rml.xsl'
368 z = zipfile.ZipFile(fname,"r")
369 mimetype = z.read('mimetype')
370 if mimetype.split('/')[-1] == 'vnd.oasis.opendocument.text' :
371 xsl_file = 'normalized_odt2rml.xsl'
372 xsl = file(os.path.join(os.getcwd(), os.path.dirname(sys.argv[0]), xsl_file)).read()
373 result = sxw2rml(f, xsl, output=opt.output, save_pict=False)
374
375 print result
376# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
377
0378
=== added file 'shipping_api_ups/sale.py'
--- shipping_api_ups/sale.py 1970-01-01 00:00:00 +0000
+++ shipping_api_ups/sale.py 2011-10-06 16:08:52 +0000
@@ -0,0 +1,34 @@
1# -*- coding: utf-8 -*-
2##############################################################################
3#
4# OpenERP, Open Source Management Solution
5# Copyright (C) 2011 NovaPoint Group LLC (<http://www.novapointgroup.com>)
6# Copyright (C) 2004-2010 OpenERP SA (<http://www.openerp.com>)
7#
8# This program is free software: you can redistribute it and/or modify
9# it under the terms of the GNU General Public License as published by
10# the Free Software Foundation, either version 3 of the License, or
11# (at your option) any later version.
12#
13# This program is distributed in the hope that it will be useful,
14# but WITHOUT ANY WARRANTY; without even the implied warranty of
15# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16# GNU General Public License for more details.
17#
18# You should have received a copy of the GNU General Public License
19# along with this program. If not, see <http://www.gnu.org/licenses/>
20#
21##############################################################################
22from osv import fields,osv
23
24class sale_order(osv.osv):
25 _inherit="sale.order"
26
27 _columns= {
28
29 'payment_method':fields.selection([('cc_pre_auth','Credit Card – PreAuthorized'),
30 ('invoice','Invoice'),
31 ('cod','COD'),
32 ('p_i_a','Pay In Advance'),],'Payment Method'),
33 }
34sale_order()
0\ No newline at end of file35\ No newline at end of file
136
=== added file 'shipping_api_ups/sale_view.xml'
--- shipping_api_ups/sale_view.xml 1970-01-01 00:00:00 +0000
+++ shipping_api_ups/sale_view.xml 2011-10-06 16:08:52 +0000
@@ -0,0 +1,16 @@
1<?xml version="1.0" encoding="UTF-8"?>
2<openerp>
3 <data>
4 <record id="sale_order_changes_for_shipping" model="ir.ui.view">
5 <field name="name">sale_order_changes_for_shipping</field>
6 <field name="model">sale.order</field>
7 <field name="type">form</field>
8 <field name="inherit_id" ref="sale.view_order_form"/>
9 <field name="arch" type="xml">
10 <xpath expr="//field[@name='pricelist_id']" position="after">
11 <field name="payment_method" invisible="1"/>
12 </xpath>
13 </field>
14 </record>
15 </data>
16</openerp>
0\ No newline at end of file17\ No newline at end of file
118
=== added directory 'shipping_api_ups/security'
=== added file 'shipping_api_ups/security/ir.model.access.csv'
--- shipping_api_ups/security/ir.model.access.csv 1970-01-01 00:00:00 +0000
+++ shipping_api_ups/security/ir.model.access.csv 2011-10-06 16:08:52 +0000
@@ -0,0 +1,5 @@
1"id","name","model_id:id","group_id:id","perm_read","perm_write","perm_create","perm_unlink"
2"security_ups_account_shipping_user","security.ups.account.shipping.user","model_ups_account_shipping","base.group_sale_salesman",1,1,1,0
3"security_ups_account_shipping_manager","security.ups.account.shipping.manager","model_ups_account_shipping","base.group_erp_manager",1,1,1,1
4"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
5"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
0\ No newline at end of file6\ No newline at end of file
17
=== added file 'shipping_api_ups/shipping_report.xml'
--- shipping_api_ups/shipping_report.xml 1970-01-01 00:00:00 +0000
+++ shipping_api_ups/shipping_report.xml 2011-10-06 16:08:52 +0000
@@ -0,0 +1,44 @@
1<?xml version="1.0"?>
2<openerp>
3 <data>
4 <report id="ship_label_print"
5 string="Print Label"
6 model="stock.packages"
7 name="ship.label.print"
8 rml="addons/shipping_api_ups/report/label_print.rml"
9 menu="False"
10 auto="False"/>
11 <report id="ship_log_label_print"
12 string="Print Label"
13 model="shipping.move"
14 name="ship.log.label.print"
15 rml="addons/shipping_api_ups/report/label_print.rml"
16 menu="False"
17 auto="False"/>
18 <report id="quick_ship_label_print"
19 string="Print Label"
20 model="quick.ship"
21 name="quick.ship.label.print"
22 rml="addons/shipping_api_ups/report/label_print.rml"
23 menu="False"
24 auto="False"/>
25 <report id="multiple_label_print"
26 string="Print Label"
27 model="stock.picking"
28 name="multiple.label.print"
29 rml="addons/shipping_api_ups/report/multiple_label_print.rml"
30 menu="False"
31 auto="False"/>
32
33
34
35 <report id="summary_report_print"
36 string="Summary Report"
37 model="shipping.move"
38 name="summary_report_print"
39 rml="addons/shipping_api_ups/report/summary_report.rml"
40 auto="False"
41 header = "False"
42 menu="True"/>
43 </data>
44</openerp>
045
=== added file 'shipping_api_ups/stock.py'
--- shipping_api_ups/stock.py 1970-01-01 00:00:00 +0000
+++ shipping_api_ups/stock.py 2011-10-06 16:08:52 +0000
@@ -0,0 +1,2921 @@
1# -*- coding: utf-8 -*-
2##############################################################################
3#
4# OpenERP, Open Source Management Solution
5# Copyright (C) 2011 NovaPoint Group LLC (<http://www.novapointgroup.com>)
6# Copyright (C) 2004-2010 OpenERP SA (<http://www.openerp.com>)
7#
8# This program is free software: you can redistribute it and/or modify
9# it under the terms of the GNU General Public License as published by
10# the Free Software Foundation, either version 3 of the License, or
11# (at your option) any later version.
12#
13# This program is distributed in the hope that it will be useful,
14# but WITHOUT ANY WARRANTY; without even the implied warranty of
15# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16# GNU General Public License for more details.
17#
18# You should have received a copy of the GNU General Public License
19# along with this program. If not, see <http://www.gnu.org/licenses/>
20#
21##############################################################################
22
23
24from osv import fields,osv
25from xml.dom.minidom import Document
26from tools.translate import _
27import httplib
28import xml2dic
29import base64
30import time
31import datetime
32from urlparse import urlparse
33import Image
34import tempfile
35import re
36
37pack_type={'01' : 'UPS Letter',
38'02' : 'Customer Supplied Package',
39'03' : 'Tube',
40'04' : 'PAK',
41'21' : 'UPS ExpressBox',
42'24' : 'UPS 25KG Box',
43'25' : 'UPS 10KG Box',
44'30' : 'Pallet',
45'2a' : 'Small Express Box',
46'2b' : 'Medium Express Box',
47'2c' : 'Large Express Box'}
48
49
50class email_template(osv.osv):
51
52 _inherit = "email.template"
53
54 _columns = {
55 'ship_mail' : fields.boolean('Ship Confirm Mail', help='Check this field to send mail when shipping is done.'),
56 }
57
58
59email_template()
60
61
62
63class shipping_move(osv.osv):
64 _inherit = "shipping.move"
65 _columns = {
66
67 'shipment_identific_no': fields.char('ShipmentIdentificationNumber', size=64, ),
68 'logo':fields.binary('Logo'),
69 'tracking_url':fields.char('Tracking URL', size=512, ),
70 'service': fields.many2one('ups.shipping.service.type', 'Shipping Service'),
71
72 }
73 def print_label(self, cr, uid, ids, context=None):
74 if not ids: return []
75
76# check_layout = self.browse(cr, uid, ids[0], context=context).company_id.check_layout
77
78 return {
79 'type': 'ir.actions.report.xml',
80 'report_name':'ship.log.label.print',
81 'datas': {
82 'model':'shipping.move',
83 'id': ids and ids[0] or False,
84 'ids': ids and ids or [],
85 'report_type': 'pdf'
86 },
87 'nodestroy': True
88 }
89 def getTrackingUrl(self,cr, uid, ids, context=None):
90 ship_log_obj = self.browse(cr, uid, ids[0], context=context)
91 if ship_log_obj.tracking_no:
92 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
93
94
95shipping_move()
96
97
98
99class stock_picking(osv.osv):
100
101 _inherit = "stock.picking"
102 _columns={
103 'ups_service': fields.many2one('ups.shipping.service.type','Service',help='The specific shipping service offered'),
104 'shipper': fields.many2one('ups.account.shipping','Shipper',help='The specific user ID and shipper. Setup in the company configuration.'),
105 'shipment_digest': fields.text('ShipmentDigest'),
106 'negotiated_rates': fields.float('NegotiatedRates'),
107 'shipment_identific_no': fields.char('ShipmentIdentificationNumber', size=64, ),
108 'tracking_no': fields.char('TrackingNumber', size=64, ),
109 'logo':fields.binary('Logo'),
110 'trade_mark': fields.related('shipper','trademark',type='char',size=1024,string='Trademark'),
111 }
112
113 def action_process(self, cr, uid, ids, context=None):
114 deliv_order = self.browse(cr, uid, type(ids)==type([]) and ids[0] or ids, context=context)
115 do_transaction = True
116 if deliv_order.sale_id and deliv_order.sale_id.payment_method == 'cc_pre_auth' and not deliv_order.sale_id.invoiced:
117
118 rel_voucher_id = deliv_order.sale_id.rel_account_voucher_id and deliv_order.sale_id.rel_account_voucher_id.id or False
119 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:
120 do_transaction = False
121 self.pool.get('account.voucher').write(cr,uid,[rel_voucher_id],{'cc_p_authorize':False,'cc_charge':True})
122 do_transaction = self.pool.get('account.voucher').authorize(cr, uid, [rel_voucher_id], context=context)
123 if not do_transaction:
124 self.write(cr,uid,ids,{'ship_state':'hold','ship_message':'Unable to process creditcard payment.'})
125 cr.commit()
126 raise osv.except_osv(_('Final credit card charge cannot be completed!'),_("Please hold shipment and contact customer service..") )
127 return super(stock_picking, self).action_process(cr, uid, ids, context=context)
128
129 def action_done(self, cr, uid, ids, context=None):
130
131 res = super(stock_picking, self).action_done(cr, uid, ids, context=context)
132 if ids:
133 for stock_pick_obj in self.pool.get('stock.picking').browse(cr,uid,ids):
134 vals={}
135 if stock_pick_obj.sale_id:
136 if stock_pick_obj.sale_id.ship_method:
137 ups_shipping_service_type_ids=self.pool.get('ups.shipping.service.type').search(cr,uid,[('description','like',stock_pick_obj.sale_id.ship_method)])
138 if ups_shipping_service_type_ids:
139 vals['ups_service']=ups_shipping_service_type_ids[0]
140 ups_shipping_service_type_obj=self.pool.get('ups.shipping.service.type').browse(cr,uid,ups_shipping_service_type_ids[0])
141 if ups_shipping_service_type_obj.ups_account_id:
142 vals['shipper']=ups_shipping_service_type_obj.ups_account_id.id
143 if ups_shipping_service_type_obj.ups_account_id.logistic_company_id:
144 vals['logis_company']=ups_shipping_service_type_obj.ups_account_id.logistic_company_id.id
145 if vals:
146 self.write(cr,uid,ids,vals)
147 return True
148 def print_labels(self, cr, uid, ids, context=None):
149 if not ids: return []
150# check_layout = self.browse(cr, uid, ids[0], context=context).company_id.check_layout
151 return {
152 'type': 'ir.actions.report.xml',
153 'report_name':'multiple.label.print',
154 'datas': {
155 'model':'stock.picking',
156 'id': ids and ids[0] or False,
157 'ids': ids and ids or [],
158 'report_type': 'pdf'
159 },
160 'nodestroy': True
161 }
162
163 def on_change_sale_id(self, cr, uid, ids, sale_id=False, state=False, context=None):
164 vals={}
165 if sale_id:
166 sale_order_obj=self.pool.get('sale.order').browse(cr,uid,sale_id)
167 ups_shipping_service_ids=self.pool.get('ups.shipping.service.type').search(cr,uid,[('description','=',sale_order_obj.ship_method)])
168
169 if type(ups_shipping_service_ids)==type([]) and len(ups_shipping_service_ids)>0:
170 vals['ups_service']=ups_shipping_service_ids[0]
171 ups_shipping_account_ids=self.pool.get('ups.account.shipping').search(cr,uid,[('ups_shipping_service_ids','in',ups_shipping_service_ids[0])])
172
173 if type(ups_shipping_account_ids)==type([]) and len(ups_shipping_account_ids)>0:
174 vals['shipper']=ups_shipping_account_ids[0]
175 logistic_company_ids=self.pool.get('logistic.company').search(cr,uid,[('ups_shipping_account_ids','in',ups_shipping_account_ids[0])])
176
177 if type(logistic_company_ids)==type([]) and len(logistic_company_ids)>0:
178 vals['logis_company']=logistic_company_ids[0]
179
180 return {'value':vals}
181
182
183 def process_void(self,cr, uid, ids, context=None):
184 error_flag = False
185 if type(ids)==type([]):
186 pick_obj=self.pool.get('stock.picking').browse(cr, uid, ids[0])
187 else:
188 pick_obj=self.pool.get('stock.picking').browse(cr, uid, ids)
189
190
191###create the acces req xml first
192 data_for_Access_Request={
193 'AccessLicenseNumber':pick_obj.shipper.id and pick_obj.shipper.accesslicensenumber or '',
194 'UserId':pick_obj.shipper.id and pick_obj.shipper.userid or '',
195 'Password':pick_obj.shipper.id and pick_obj.shipper.password or ''
196 }
197 response = ''
198 for pack in pick_obj.packages_ids:
199
200 data_for_void_shipment={'VoidShipmentRequest':{'Request':{
201 'RequestAction':"1",
202 'TransactionReference':{'CustomerContext':"",},
203 },
204 'ShipmentIdentificationNumber':pack.shipment_identific_no or '',
205
206 'ExpandedVoidShipment':{
207 'ShipmentIdentificationNumber':pack.shipment_identific_no or '',
208 'TrackingNumber':pack.tracking_no or ''
209 }
210 }
211 }
212
213
214 doc2=Document()
215 VoidShipmentRequest = doc2.createElement("VoidShipmentRequest")
216 doc2.appendChild(VoidShipmentRequest)
217
218 Request = doc2.createElement("Request")
219 VoidShipmentRequest.appendChild(Request)
220
221
222 RequestAction = doc2.createElement("RequestAction")
223 ptext = doc2.createTextNode(data_for_void_shipment["VoidShipmentRequest"]['Request']['RequestAction'])
224 RequestAction.appendChild(ptext)
225 Request.appendChild(RequestAction)
226
227 TransactionReference = doc2.createElement("TransactionReference")
228 Request.appendChild(TransactionReference)
229
230 CustomerContext = doc2.createElement("CustomerContext")
231 ptext = doc2.createTextNode(data_for_void_shipment["VoidShipmentRequest"]['Request']['TransactionReference']['CustomerContext'])
232 CustomerContext.appendChild(ptext)
233 TransactionReference.appendChild(CustomerContext)
234
235# ShipmentIdentificationNumber = doc2.createElement("ShipmentIdentificationNumber")
236# ptext = doc2.createTextNode(data_for_void_shipment["VoidShipmentRequest"]['ShipmentIdentificationNumber'])
237# ShipmentIdentificationNumber.appendChild(ptext)
238# VoidShipmentRequest.appendChild(ShipmentIdentificationNumber)
239 #
240
241
242 ExpandedVoidShipment = doc2.createElement("ExpandedVoidShipment")
243 VoidShipmentRequest.appendChild(ExpandedVoidShipment)
244
245 ShipmentIdentificationNumber = doc2.createElement("ShipmentIdentificationNumber")
246 ptext = doc2.createTextNode(data_for_void_shipment["VoidShipmentRequest"]['ExpandedVoidShipment']['ShipmentIdentificationNumber'])
247 ShipmentIdentificationNumber.appendChild(ptext)
248 ExpandedVoidShipment.appendChild(ShipmentIdentificationNumber)
249
250 TrackingNumber = doc2.createElement("TrackingNumber")
251 ptext = doc2.createTextNode(data_for_void_shipment["VoidShipmentRequest"]['ExpandedVoidShipment']['TrackingNumber'])
252 TrackingNumber.appendChild(ptext)
253 ExpandedVoidShipment.appendChild(TrackingNumber)
254
255 Request_string2=doc2.toprettyxml()
256
257
258
259 doc1 = Document()
260 AccessRequest = doc1.createElement("AccessRequest")
261 AccessRequest.setAttribute("xml:lang", "en-US")
262 doc1.appendChild(AccessRequest)
263
264
265 AccessLicenseNumber = doc1.createElement("AccessLicenseNumber")
266 ptext = doc1.createTextNode(data_for_Access_Request["AccessLicenseNumber"])
267 AccessLicenseNumber.appendChild(ptext)
268 AccessRequest.appendChild(AccessLicenseNumber)
269
270 UserId = doc1.createElement("UserId")
271 ptext = doc1.createTextNode(data_for_Access_Request["UserId"])
272 UserId.appendChild(ptext)
273 AccessRequest.appendChild(UserId)
274
275 Password = doc1.createElement("Password")
276 ptext = doc1.createTextNode(data_for_Access_Request["Password"])
277 Password.appendChild(ptext)
278 AccessRequest.appendChild(Password)
279
280 Request_string1=doc1.toprettyxml()
281
282 Request_string=Request_string1+Request_string2
283
284
285# Request_string = '''<?xml version="1.0" ?>
286#<AccessRequest xml:lang='en-US'>
287#<AccessLicenseNumber>3C70E997ECE04388</AccessLicenseNumber>
288#<UserId>kdunn.cva</UserId>
289#<Password>heckethorn</Password>
290#</AccessRequest>
291#<?xml version="1.0" encoding="UTF-8" ?>
292#<VoidShipmentRequest>
293#<Request>
294#<TransactionReference>
295#<CustomerContext>Customer Transaction ID</CustomerContext>
296#<XpciVersion>1.0001</XpciVersion>
297#</TransactionReference>
298#<RequestAction>Void</RequestAction>
299#<RequestOption />
300#</Request>
301#<ExpandedVoidShipment>
302#<ShipmentIdentificationNumber>
303#1Z2220060294314162
304#</ShipmentIdentificationNumber>
305#<TrackingNumber>1Z2220060291994175</TrackingNumber>
306#</ExpandedVoidShipment>
307#</VoidShipmentRequest>'''
308 if pick_obj.logis_company.test_mode:
309 void_web = pick_obj.logis_company.ship_void_test_web or ''
310 void_port = pick_obj.logis_company.ship_void_test_port
311 else:
312 void_web = pick_obj.logis_company.ship_void_web or ''
313 void_port = pick_obj.logis_company.ship_void_port
314 if void_web:
315 parse_url = urlparse(void_web)
316 serv = parse_url.netloc
317 serv_path = parse_url.path
318 else:
319 raise osv.except_osv(_('Unable to find Shipping URL!'),_("Please configure the shipping company with websites.") )
320
321
322 conn=httplib.HTTPSConnection(serv,void_port)
323 res=conn.request("POST",serv_path,Request_string)
324 res=conn.getresponse()
325 result = res.read()
326 response_dic=xml2dic.main(result)
327 response = ''
328 error_flag=False
329 for elm in response_dic['VoidShipmentResponse'][0]['Response']:
330 if 'ResponseStatusCode' in elm.keys():
331 response += 'ResponseStatusCode:'+str(elm['ResponseStatusCode'])+'\n'
332 if 'ResponseStatusDescription' in elm.keys():
333 response += 'ResponseStatusDescription:'+str(elm['ResponseStatusDescription'])+'\n'
334 if 'Error' in elm.keys():
335 error_flag = True
336 response += 'Error:'+str(elm['Error'])+'\n'
337
338
339 response = 'Void:\n'+response
340 self.pool.get('stock.packages').write(cr,uid,pack.id,{'ship_message':str(response)})
341
342 if not error_flag:
343 self.pool.get('stock.picking').write(cr, uid, ids,{'ship_state':'void','ship_message':''})
344 else:
345 self.pool.get('stock.picking').write(cr, uid, ids,{'ship_message':response})
346 return True
347
348
349 def get_package(self,pack_obj):
350 if not pack_obj:
351 return []
352 else:
353 ret = []
354 ret.append({
355 'Description':"",'PackagingType':{'Code':pack_obj.package_type or "",'Description':pack_type.get(pack_obj.package_type , "")},#PackagingType
356 '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
357 'PackageWeight':{'UnitOfMeasurement':{'Code':"LBS",'Description':"Pounds"},'Weight':str(pack_obj.weight or "0")},
358# 'LargePackageIndicator':"",
359 'ReferenceNumber':{'BarCodeIndicator':"",'Code':pack_obj.ref1 or "",'Value':""},
360# 'AdditionalHandling':"",
361# 'PackageServiceOptions':{'DeliveryConfirmation':{'DCISType':"",'DCISNumber':""},#DeliveryConfirmation
362# 'InsuredValue':{'Type':"",'Code':"",'Description':"",
363# 'CurrencyCode':"",'MonetaryValue':""
364# },#InsuredValue
365# 'COD':{'CODCode':"",'CODFundsCode':"",
366# 'CODAmount':{'CurrencyCode':"",
367# 'MonetaryValue':""
368# },#CODAmount
369# },#COD
370# 'VerbalConfirmation':{ContactInfo:{'Name':"",'PhoneNumber':""}#ContactInfo
371# },#VerbalConfirmation
372# 'ShipperReleaseIndicator':"",
373# 'Notification':{'NotificationCode':"",
374# 'EMailMessage':{'EMailAddress':"",'UndeliverableEMailAddress':"",
375# 'FromEMailAddress':"",'FromName':"",'Memo':"",
376# 'Subject':"",'SubjectCode':""}#EMailMessage
377# },#Notification,
378# 'ReturnsFlexibleAccessIndicator':"",
379# }#PackageServiceOptions
380 })
381 return ret
382
383 def fill_addr(self,addr_id):
384 ret = {'AddressLine1':addr_id and addr_id.street or '',
385 'AddressLine2':addr_id and addr_id.street2 or '',
386 'AddressLine3':"",
387 'City':addr_id and addr_id.city or '',
388 'StateProvinceCode':addr_id and addr_id.state_id.id and addr_id.state_id.code or '',
389 'PostalCode':addr_id and addr_id.zip or '',
390 'CountryCode':addr_id and addr_id.country_id.id and addr_id.country_id.code or '',
391 'ResidentialAddress':"",
392 }
393
394 if addr_id and ('zip_id' in addr_id._columns.keys()):
395 ret['PostalCode'] = addr_id.zip_id.id and str(addr_id.zip_id.zipcode) or ''
396 return ret
397
398 def create_ship_accept_request(self,cr, uid, ids,package_id):
399 package_obj=self.pool.get('stock.packages').browse(cr, uid, package_id)
400
401###create the acces req xml first
402 data_for_Access_Request={
403 'AccessLicenseNumber':package_obj.pick_id.shipper.id and package_obj.pick_id.shipper.accesslicensenumber or '',
404 'UserId':package_obj.pick_id.shipper.id and package_obj.pick_id.shipper.userid or '',
405 'Password':package_obj.pick_id.shipper.id and package_obj.pick_id.shipper.password or ''
406 }
407
408 doc1 = Document()
409 AccessRequest = doc1.createElement("AccessRequest")
410 AccessRequest.setAttribute("xml:lang", "en-US")
411 doc1.appendChild(AccessRequest)
412
413
414 AccessLicenseNumber = doc1.createElement("AccessLicenseNumber")
415 ptext = doc1.createTextNode(data_for_Access_Request["AccessLicenseNumber"])
416 AccessLicenseNumber.appendChild(ptext)
417 AccessRequest.appendChild(AccessLicenseNumber)
418
419 UserId = doc1.createElement("UserId")
420 ptext = doc1.createTextNode(data_for_Access_Request["UserId"])
421 UserId.appendChild(ptext)
422 AccessRequest.appendChild(UserId)
423
424 Password = doc1.createElement("Password")
425 ptext = doc1.createTextNode(data_for_Access_Request["Password"])
426 Password.appendChild(ptext)
427 AccessRequest.appendChild(Password)
428
429 Request_string1=doc1.toprettyxml()
430
431
432
433 data_for_Ship_Accept = {'ShipmentAcceptRequest':{
434 'Request':{
435 'RequestAction':'ShipAccept',
436 'TransactionReference':{'CustomerContext':''}
437 },
438 'ShipmentDigest':package_obj.shipment_digest
439 }
440 }
441
442
443 doc2 = Document()
444 ShipmentAcceptRequest = doc2.createElement("ShipmentAcceptRequest")
445 ShipmentAcceptRequest.setAttribute("xml:lang", "en-US")
446 doc2.appendChild(ShipmentAcceptRequest)
447
448
449
450 Request = doc2.createElement("Request")
451 ShipmentAcceptRequest.appendChild(Request)
452
453
454 RequestAction = doc2.createElement("RequestAction")
455 ptext = doc1.createTextNode(data_for_Ship_Accept['ShipmentAcceptRequest']["Request"]['RequestAction'])
456 RequestAction.appendChild(ptext)
457 Request.appendChild(RequestAction)
458
459
460 TransactionReference = doc2.createElement("TransactionReference")
461 Request.appendChild(TransactionReference)
462
463 CustomerContext = doc2.createElement("CustomerContext")
464 ptext = doc1.createTextNode(data_for_Ship_Accept['ShipmentAcceptRequest']["Request"]['TransactionReference']['CustomerContext'])
465 CustomerContext.appendChild(ptext)
466 TransactionReference.appendChild(CustomerContext)
467
468 ShipmentDigest = doc2.createElement("ShipmentDigest")
469 ptext = doc1.createTextNode(data_for_Ship_Accept['ShipmentAcceptRequest']["ShipmentDigest"])
470 ShipmentDigest.appendChild(ptext)
471 ShipmentAcceptRequest.appendChild(ShipmentDigest)
472
473 Request_string2=doc2.toprettyxml()
474 request_string=Request_string1+Request_string2
475
476 return request_string
477
478 def process_ship_accept(self,cr, uid, ids,ship_move_ids,pack_obj,context=None):
479
480
481 shipment_accept_request_xml=self.create_ship_accept_request(cr, uid, ids,pack_obj.id)
482
483 if pack_obj.pick_id.logis_company.test_mode:
484 acce_web = pack_obj.pick_id.logis_company.ship_accpt_test_web or ''
485 acce_port = pack_obj.pick_id.logis_company.ship_accpt_test_port
486 else:
487 acce_web = pack_obj.pick_id.logis_company.ship_accpt_web or ''
488 acce_port = pack_obj.pick_id.logis_company.ship_accpt_port
489 if acce_web:
490 parse_url = urlparse(acce_web)
491 serv = parse_url.netloc
492 serv_path = parse_url.path
493 else:
494 raise osv.except_osv(_('Unable to find Shipping URL!'),_("Please configure the shipping company with websites.") )
495
496
497
498 conn=httplib.HTTPSConnection(serv,acce_port)
499 res=conn.request("POST",serv_path,shipment_accept_request_xml)
500 res=conn.getresponse()
501 result = res.read()
502 response_dic=xml2dic.main(result)
503 NegotiatedRates=''
504 ShipmentIdentificationNumber=''
505 TrackingNumber=''
506 label_image=''
507 if response_dic['ShipmentAcceptResponse'][0]['Response'][0]['ResponseStatusCode'] == '1':
508 if len(response_dic['ShipmentAcceptResponse'])>1 and response_dic['ShipmentAcceptResponse'][1].has_key('ShipmentResults'):
509 if len(response_dic['ShipmentAcceptResponse'][1]['ShipmentResults'])>1 and response_dic['ShipmentAcceptResponse'][1]['ShipmentResults'][1].has_key('NegotiatedRates'):
510 if len(response_dic['ShipmentAcceptResponse'][1]['ShipmentResults'][1]['NegotiatedRates'])>0 and response_dic['ShipmentAcceptResponse'][1]['ShipmentResults'][1]['NegotiatedRates'][0].has_key('NetSummaryCharges'):
511 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'):
512 NegotiatedRates=response_dic['ShipmentAcceptResponse'][1]['ShipmentResults'][1]['NegotiatedRates'][0]['NetSummaryCharges'][0]['GrandTotal'][1]['MonetaryValue']
513
514 if len(response_dic['ShipmentAcceptResponse'][1]['ShipmentResults'])>0 and response_dic['ShipmentAcceptResponse'][1]['ShipmentResults'][3].has_key('ShipmentIdentificationNumber'):
515 ShipmentIdentificationNumber=response_dic['ShipmentAcceptResponse'][1]['ShipmentResults'][3]['ShipmentIdentificationNumber']
516
517 if len(response_dic['ShipmentAcceptResponse'][1]['ShipmentResults'])>4 and response_dic['ShipmentAcceptResponse'][1]['ShipmentResults'][4].has_key('PackageResults') :
518 if len(response_dic['ShipmentAcceptResponse'][1]['ShipmentResults'][4]['PackageResults'])>0:
519 TrackingNumber=response_dic['ShipmentAcceptResponse'][1]['ShipmentResults'][4]['PackageResults'][0]['TrackingNumber']
520
521 if len(response_dic['ShipmentAcceptResponse'][1]['ShipmentResults'][4]['PackageResults'])>2 and response_dic['ShipmentAcceptResponse'][1]['ShipmentResults'][4]['PackageResults'][2].has_key('LabelImage') :
522 label_image =response_dic['ShipmentAcceptResponse'][1]['ShipmentResults'][4]['PackageResults'][2]['LabelImage'][1]['GraphicImage']
523 if TrackingNumber:
524 tracking_url = pack_obj.pick_id.logis_company.ship_tracking_url
525 if tracking_url:
526 try:
527 tracking_url = tracking_url%TrackingNumber
528 except Exception, e:
529 tracking_url = "Invalid tracking url on shipping company"
530# 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
531 else:
532 tracking_url = ''
533 if label_image:
534 im_in_raw=base64.decodestring(label_image)
535 path=tempfile.mktemp()
536 temp=file(path,'wb')
537 temp.write(im_in_raw)
538 temp.close()
539 new_im=Image.open(path)
540 new_im=new_im.rotate(270)
541 new_im.save(path,'JPEG')
542 label_from_file=open(path,'rb')
543 label_image=base64.encodestring(label_from_file.read())
544 label_from_file.close()
545
546 self.pool.get('stock.packages').write(cr,uid,[pack_obj.id],{'tracking_no':TrackingNumber or "",
547 'shipment_identific_no':ShipmentIdentificationNumber or "",
548 'negotiated_rates':NegotiatedRates or '',
549 'logo':label_image,
550 'ship_state':'in_process',
551 'tracking_url':tracking_url})
552
553 if ship_move_ids.get(pack_obj.id):
554 if TrackingNumber:
555 tracking_url = pack_obj.pick_id.logis_company.ship_tracking_url
556 if tracking_url:
557 try:
558 tracking_url = tracking_url%TrackingNumber
559 except Exception, e:
560 tracking_url = "Invalid tracking url on shipping company"
561 else:
562 tracking_url = ''
563 self.pool.get('shipping.move').write(cr, uid, [ship_move_ids.get(pack_obj.id)], {'tracking_no':TrackingNumber or "",
564 'shipment_identific_no':ShipmentIdentificationNumber or "",
565 'ship_cost':NegotiatedRates or '',
566 'logo':label_image,
567 'state':'ready_pick',
568 'tracking_url':tracking_url})
569# t_string="Package id : "+str(pack_obj.id)
570# t_string+="\n"+(pack_obj.pick_id.ship_message or '')
571# self.pool.get('stock.picking').write(cr, uid,[pack_obj.pick_id.id], {'ship_message': t_string})
572
573 return True
574 def add_product(self, cr, uid, package_obj):
575 prods = []
576 tot_weight = 0
577 for pkg in package_obj.pick_id.packages_ids:
578 tot_weight += pkg.weight
579 for move_lines in package_obj.pick_id.move_lines:
580 product_id = move_lines.product_id
581 if move_lines.product_id.supply_method == 'produce':
582 produce = "Yes"
583 else:
584 produce = "NO[1]"
585 product={'Description':move_lines.product_id.description or " ",
586 'Unit':{'Number':str(int(move_lines.product_qty) or 0),
587 'Value':str((move_lines.product_id.list_price * move_lines.product_qty) or 0),
588 'UnitOfMeasurement':{'Code':"LBS",'Description':"Pounds"}
589 },
590 'CommodityCode':package_obj.pick_id.comm_code or "",
591 'PartNumber':"",
592 '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 "",
593 'JointProductionIndicator':"",
594 'NetCostCode':"NO",
595# 'NetCostDateRange':{'BeginDate':"",'EndDate':""}, Not required
596 'PreferenceCriteria':"B",
597 'ProducerInfo':produce,
598 'MarksAndNumbers':"",
599 'NumberOfPackagesPerCommodity':str(len(package_obj.pick_id.packages_ids)),
600 'ProductWeight':{'UnitOfMeasurement':{'Code':"LBS",'Description':"Pounds"},
601 'Weight':"%.1f"%(tot_weight or '0')},
602 'VehicleID':"",
603# THis is only needed for sed
604# 'ScheduleB':{'Number':"",
605# 'Quantity':"",
606# 'UnitOfMeasurement':{'Code':"",'Description':""},
607# 'ExportType':"",
608# 'SEDTotalValue':""
609# },
610 }
611 prods.append(product)
612 return prods
613 def create_comm_inv(self, cr, uid, package_obj):
614 invoice_id = False
615 if package_obj.pick_id.sale_id:
616 if package_obj.pick_id.sale_id.invoice_ids:
617 invoice_id = package_obj.pick_id.sale_id.invoice_ids[0]
618 user = self.pool.get('res.users').browse(cr, uid, uid)
619 comm_inv={ 'FormType':"01",
620# 'AdditionalDocumentIndicator':"", Not required
621# 'FormGroupIdName':"", Not required
622 'Product':[],#Placed out of this dictionary for common use
623 'InvoiceNumber':"",
624 'InvoiceDate':"",
625 'PurchaseOrderNumber':"",
626 'TermsOfShipment':"",
627 'ReasonForExport':"SALE",
628 'Comments':"",
629 '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.",
630# 'Discount':{'MonetaryValue':"0"},#Discount Not Required
631# 'FreightCharges':{'MonetaryValue':""},#FreightCharges Not Required
632# 'InsuranceCharges':{'MonetaryValue':""},#InsuranceCharges Not Required
633# 'OtherCharges':{'MonetaryValue':"",'Description':""},#OtherCharges Not Required
634 'CurrencyCode':user.company_id.currency_id.name or "",
635# 'InBondCode':"", Not Required
636# 'EntryNumber':"", Not Required
637# 'PointOfOrigin':"", Not Required
638 }
639 if invoice_id:
640 comm_inv['InvoiceNumber'] = invoice_id.number or '/'
641 if invoice_id.date_invoice:
642 d=invoice_id.date_invoice
643 comm_inv['InvoiceDate'] = d[:4]+d[5:7]+d[8:10]
644 if not comm_inv['InvoiceDate']:
645 comm_inv['InvoiceDate'] = time.strftime("%Y%m%d")
646
647 return comm_inv
648 def create_cer_orig(self, cr, uid, package_obj):
649 cer_orig={
650 'FormType':"03",
651# 'AdditionalDocumentIndicator':"", Not Required
652# 'FormGroupIdName':"", Not Required
653 'Product':[],#Placed out of this dictionary for common use
654 'ExportDate':time.strftime("%Y%m%d"),
655 'ExportingCarrier':package_obj.pick_id.exp_carrier or "",
656 }
657 return cer_orig
658 def create_nafta_cer_orig(self, cr, uid, package_obj):
659 addr = {}
660 if package_obj.pick_id.prod_address_id:
661 addr_id = package_obj.pick_id.prod_address_id
662
663 addr = {'AddressLine1':addr_id.street or "",
664 'AddressLine2':addr_id.street2 or "",
665 'City':addr_id.city or "",
666 'StateProvinceCode':addr_id.state_id and addr_id.state_id.code or "",
667 'PostalCode':addr_id.zip or "",
668 'CountryCode':addr_id.country_id and addr_id.country_id.code or "",
669 }
670 beg_date=" "
671 end_date=" "
672 if package_obj.pick_id.blanket_begin_date:
673 beg_date = package_obj.pick_id.blanket_begin_date
674 beg_date = beg_date[:4]+beg_date[5:7]+beg_date[8:10]
675 if package_obj.pick_id.blanket_end_date:
676 end_date = package_obj.pick_id.blanket_end_date
677 end_date = end_date[:4]+end_date[5:7]+end_date[8:10]
678 nafta_cer_orig={ 'FormType':"04",
679# 'AdditionalDocumentIndicator':"", Not Required
680# 'FormGroupIdName':"", Not Required
681 'Contacts':{
682
683 'Producer':{'Option':package_obj.pick_id.prod_option or "",
684 'CompanyName':package_obj.pick_id.prod_company or "",
685 'TaxIdentificationNumber':package_obj.pick_id.prod_tax_id_no or "",
686 'Address':addr,#Address
687 },#Producer
688 },#Contacts
689 'BlanketPeriod':{
690 'BeginDate':beg_date,
691 'EndDate':end_date,
692
693 },
694 'Product':[],#Placed out of this dictionary for common use
695 }
696 return nafta_cer_orig
697# def create_sed(self, package_obj):
698# sed ={ 'FormType':"02",
699# 'AdditionalDocumentIndicator':"",
700# 'FormGroupIdName':"",
701# 'SEDFilingOption':"01",
702# 'Contacts':{
703# 'ForwardAgent':{'CompanyName':"",
704# 'TaxIdentificationNumber':"",
705# 'Address':{'AddressLine1':"",
706# 'AddressLine2':"",
707# 'City':"",
708# 'StateProvinceCode':"",
709# 'PostalCode':"",
710# 'CountryCode':"",
711# },#Address
712#
713# },#ForwardAgent
714# 'UltimateConsignee':{'CompanyName':"",
715# 'Address':{'AddressLine1':"",
716# 'AddressLine2':"",
717# 'City':"",
718# 'StateProvinceCode':"",
719# 'PostalCode':"",
720# 'CountryCode':"",
721# },#Address
722# },#UltimateConsignee
723#
724# 'IntermediateConsignee':{'CompanyName':"",
725# 'Address':{'AddressLine1':"",
726# 'AddressLine2':"",
727# 'City':"",
728# 'StateProvinceCode':"",
729# 'PostalCode':"",
730# 'CountryCode':"",
731# },#Address
732# },#IntermediateConsignee
733#
734# 'Producer':{'Option':"",
735# 'CompanyName':"",
736# 'TaxIdentificationNumber':"",
737# 'Address':{'AddressLine1':"",
738# 'AddressLine2':"",
739# 'City':"",
740# 'StateProvinceCode':"",
741# 'PostalCode':"",
742# 'CountryCode':"",
743# },#Address
744# },#Producer
745# },#Contacts
746# 'Product':[],#Placed out of this dictionary for common use
747# 'ExportDate':"",
748# 'ExportingCarrier':"",
749# 'CarrierID':"",
750# 'InBondCode':"",
751# 'EntryNumber':"",
752# 'PointOfOrigin':"",
753# 'ModeOfTransport':"",
754# 'PortOfExport':"",
755# 'PortOfUnloading':"",
756# 'LoadingPier':"",
757# 'PartiesToTransaction':"",
758# 'RoutedExportTransactionIndicator':False,#Make it true to add this
759# 'ContainerizedIndicator':False,#Make it true to add this
760# 'License':{ 'Number':"",
761# 'Date':"",
762# 'ExceptionCode':"",},
763# 'ECCNNumber':"",
764# }
765# return sed
766
767 def create_forms(self, cr, uid, package_obj):
768 comm_inv = {}
769 cer_orig = {}
770 nafta_cer_orig = {}
771 sed = {}
772 if package_obj.pick_id.comm_inv:
773 comm_inv = self.create_comm_inv(cr, uid, package_obj)
774 if package_obj.pick_id.cer_orig:
775 cer_orig = self.create_cer_orig(cr, uid, package_obj)
776 if package_obj.pick_id.nafta_cer_orig:
777 nafta_cer_orig = self.create_nafta_cer_orig(cr, uid, package_obj)
778# if package_obj.pick_id.sed:
779# sed = self.create_sed(package_obj)
780 prod = self.add_product(cr, uid, package_obj)
781# asd
782 ret = {'comm_inv':comm_inv,'cer_orig':cer_orig,'nafta_cer_orig':nafta_cer_orig,'sed':sed,'prod':prod}
783 return ret
784 def create_ship_confirm_request(self,cr, uid,package_id):
785 package_obj=self.pool.get('stock.packages').browse(cr, uid, package_id)
786
787###create the acces req xml first
788 data_for_Access_Request={
789 'AccessLicenseNumber':package_obj.pick_id.shipper.id and package_obj.pick_id.shipper.accesslicensenumber or '',
790 'UserId':package_obj.pick_id.shipper.id and package_obj.pick_id.shipper.userid or '',
791 'Password':package_obj.pick_id.shipper.id and package_obj.pick_id.shipper.password or ''
792 }
793
794 doc1 = Document()
795 AccessRequest = doc1.createElement("AccessRequest")
796 AccessRequest.setAttribute("xml:lang", "en-US")
797 doc1.appendChild(AccessRequest)
798
799
800 AccessLicenseNumber = doc1.createElement("AccessLicenseNumber")
801 ptext = doc1.createTextNode(data_for_Access_Request["AccessLicenseNumber"])
802 AccessLicenseNumber.appendChild(ptext)
803 AccessRequest.appendChild(AccessLicenseNumber)
804
805 UserId = doc1.createElement("UserId")
806 ptext = doc1.createTextNode(data_for_Access_Request["UserId"])
807 UserId.appendChild(ptext)
808 AccessRequest.appendChild(UserId)
809
810 Password = doc1.createElement("Password")
811 ptext = doc1.createTextNode(data_for_Access_Request["Password"])
812 Password.appendChild(ptext)
813 AccessRequest.appendChild(Password)
814
815 Request_string1=doc1.toprettyxml()
816
817
818###create the shipment acces req xml
819 data_for_confirm_request={'ShipmentConfirmRequest':{
820
821 'Request':{'RequestAction':"ShipConfirm",#-----must be ShipConfirm
822 'RequestOption':package_obj.pick_id.address_validate or "nonvalidate",#----------adress validation
823 'TransactionReference':{'CustomerContext':"",},#---------optional data
824 },#Request
825
826 'Shipment':{'Description':package_obj.description or "Shipping",
827 'ReturnService':{'Code':"8", 'DocumentsOnly':"" },
828 'Shipper':{ 'Name':package_obj.pick_id.shipper.id and package_obj.pick_id.shipper.name or "",
829 'AttentionName':package_obj.pick_id.shipper.id and package_obj.pick_id.shipper.atten_name or "",
830 'ShipperNumber':package_obj.pick_id.shipper.id and package_obj.pick_id.shipper.acc_no or "",
831 'TaxIdentificationNumber':package_obj.pick_id.shipper.id and package_obj.pick_id.shipper.tax_id_no or "",
832 'PhoneNumber':package_obj.pick_id.shipper.id and package_obj.pick_id.shipper.address and package_obj.pick_id.shipper.address.phone or "",
833 'FaxNumber':package_obj.pick_id.shipper.id and package_obj.pick_id.shipper.address and package_obj.pick_id.shipper.address.fax or "",
834 'EMailAddress':package_obj.pick_id.shipper.id and package_obj.pick_id.shipper.address and package_obj.pick_id.shipper.address.email or "",
835 'Address':self.fill_addr(package_obj.pick_id.shipper.id and package_obj.pick_id.shipper.address or '')
836 },#Shipper
837
838 'ShipTo': {'CompanyName':package_obj.pick_id.address_id.partner_id and package_obj.pick_id.address_id.partner_id.name or '',
839 'AttentionName':package_obj.pick_id.inv_att_name or "",
840 'TaxIdentificationNumber':"",
841 'PhoneNumber':package_obj.pick_id.address_id.id and package_obj.pick_id.address_id.phone or '',
842 'FaxNumber':package_obj.pick_id.address_id.id and package_obj.pick_id.address_id.fax or '',
843 'EMailAddress':package_obj.pick_id.address_id.id and package_obj.pick_id.address_id.email or '',
844 'Address':self.fill_addr(package_obj.pick_id.address_id.id and package_obj.pick_id.address_id),
845 'LocationID':"",
846 },#ShipTo
847
848
849
850 'ShipFrom':{'CompanyName':package_obj.pick_id.shipper.id and package_obj.pick_id.shipper.name or "",
851 'AttentionName':package_obj.pick_id.shipper.id and package_obj.pick_id.shipper.atten_name or "",
852 'TaxIdentificationNumber':package_obj.pick_id.ship_from_tax_id_no or '',
853 'PhoneNumber':package_obj.pick_id.address_id.id and package_obj.pick_id.ship_from_address.phone or '',
854 'FaxNumber':package_obj.pick_id.address_id.id and package_obj.pick_id.ship_from_address.fax or '',
855 'Address':self.fill_addr(package_obj.pick_id.ship_from_address.id and package_obj.pick_id.ship_from_address),
856 },
857
858 'SoldTo':{'Option':package_obj.pick_id.inv_option or " ",
859 'CompanyName':package_obj.pick_id.inv_company or "",
860 'AttentionName':package_obj.pick_id.inv_att_name or "",
861 'TaxIdentificationNumber':package_obj.pick_id.inv_tax_id_no or "",
862 'PhoneNumber':package_obj.pick_id.inv_address_id and package_obj.pick_id.inv_address_id.phone or "",
863 'Address':{'AddressLine1':package_obj.pick_id.inv_address_id and package_obj.pick_id.inv_address_id.street or "",
864 'AddressLine2':package_obj.pick_id.inv_address_id and package_obj.pick_id.inv_address_id.street2 or "",
865 'City':package_obj.pick_id.inv_address_id and package_obj.pick_id.inv_address_id.city or "",
866 '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 "",
867 'PostalCode':package_obj.pick_id.inv_address_id and package_obj.pick_id.inv_address_id.zip or "",
868 '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 "",}
869 },#SoldTo,
870
871 'PaymentInformation':{'Prepaid':{
872 'BillShipper':{'AccountNumber':package_obj.pick_id.shipper and package_obj.pick_id.shipper.acc_no or "",
873# 'CreditCard':{'Type':"",
874# 'Number':"",
875# 'ExpirationDate':"",
876# 'SecurityCode':"",
877# 'Address':{'AddressLine1':"",
878# 'AddressLine2':"",
879# 'AddressLine3':"",
880# 'City':"",
881# 'StateProvinceCode':"",
882# 'PostalCode':"",
883# 'CountryCode':"",},
884# },#CreditCard
885 },#BillShipper
886 },#Prepaid
887# 'BillThirdParty':{'BillThirdPartyShipper':{'AccountNumber':"",
888# 'ThirdParty':{
889# 'Address':{'PostalCode':"",
890# 'CountryCode':"",},#Address
891# },#ThirdParty
892# },#BillThirdPartyShipper
893#
894# },#BillThirdParty
895#
896# 'FreightCollect':{'BillReceiver':{'AccountNumber':"",
897# 'Address':{'PostalCode':"",},#Address
898# },#BillReceiver
899# },#FreightCollect
900#
901# 'ConsigneeBilled':"",
902 },#PaymentInformation,
903
904# 'ItemizedPaymentInformation':{ 'ShipmentCharge':{'Type':"",
905# 'BillShipper':{'AccountNumber':"",
906# 'CreditCard':{'Type':"",
907# 'Number':"",
908# 'ExpirationDate':"",
909# 'SecurityCode':"",
910# 'Address':{'AddressLine1':"",
911# 'AddressLine2':"",
912# 'AddressLine3':"",
913# 'City':"",
914# 'StateProvinceCode':"",
915# 'PostalCode':"",
916# 'CountryCode':"",},
917# },#CreditCard
918# },#BillShipper
919# 'BillReceiver':{'AccountNumber':"",'Address':{'PostalCode':"",},#Address
920# },#BillReceiver
921# 'BillThirdParty':{'BillThirdPartyShipper':{'AccountNumber':"",
922# 'ThirdParty':{
923# 'Address':{'PostalCode':"",'CountryCode':"",},#Address
924# },#ThirdParty
925# },#BillThirdPartyShipper
926#
927# 'BillThirdPartyConsignee':{'AccountNumber':"",'ThirdParty':{'Address':{'PostalCode':"",
928# 'CountryCode':"",}, #Address
929# },#ThirdParty
930# },#BillThirdPartyConsignee
931# },#BillThirdParty
932# 'ConsigneeBilled':"",
933# },#ShipmentCharge
934# 'SplitDutyVATIndicator':"",
935# },#ItemizedPaymentInformation
936
937 'GoodsNotInFreeCirculationIndicator':"",
938 'RateInformation':{'NegotiatedRatesIndicator':""},#RateInformation
939# 'MovementReferenceNumber':"",
940# 'ReferenceNumber':{'BarCodeIndicator':"",'Code':"",'Value':"",},#ReferenceNumber,
941 'Service':{'Code':package_obj.pick_id.ups_service.id and str(package_obj.pick_id.ups_service.shipping_service_code) or "",
942 'Description':package_obj.pick_id.ups_service.id and package_obj.pick_id.ups_service.description or ""},#Service
943 'InvoiceLineTotal':{'CurrencyCode':"",'MonetaryValue':str(int(package_obj.pick_id.sale_id.amount_total)) or ""},#InvoiceLineTotal
944 'ShipmentServiceOptions':{'SaturdayDelivery':"",
945# 'COD':{'CODCode':"",'CODFundsCode':"",
946# 'CODAmount':{'CurrencyCode':"",
947# 'MonetaryValue':""
948# },#CODAmount
949# },#COD
950 'Notification':[],
951 'LabelDelivery':{'LabelLinkIndicator':"",
952 'EMailMessage':{'EMailAddress':"mail@mail.com",
953 'UndeliverableEMailAddress':"",
954 'FromEMailAddress':"mail@mail.com",
955 'FromName':"",
956 'Memo':"",
957 'Subject':"",
958 'SubjectCode':""}#EMailMessage
959 },#LabelDelivery
960
961 'InternationalForms':self.create_forms(cr, uid, package_obj),#InternationalForms
962# 'ReturnOfDocumentIndicator':"",
963# 'ImportControlIndicator':"",
964# 'LabelMethod':{'Code':"",'Description':"",},#LabelMethod
965# 'CommercialInvoiceRemovalIndicator':"",
966# 'UPScarbonneutralIndicator':"",
967# 'DeliveryConfirmation':{'DCISType':"1",}#DeliveryConfirmation
968 },#ShipmentServiceOptions,
969 'Package':self.get_package(package_obj)## this is done in different file
970 },#Shipment
971 'LabelSpecification':{'LabelPrintMethod':{'Code':"GIF", 'Description':"GIF",},
972 'HTTPUserAgent':"",
973 'LabelStockSize':{'Height':"6",'Width':"6"},
974 'LabelImageFormat':{'Code':"GIF",'Description':"GIF"},
975 },#LabelSpecification
976
977 },#ShipmentConfirmRequest
978 }
979
980
981
982
983 comm_inv = data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["ShipmentServiceOptions"]["InternationalForms"]['comm_inv']
984 cer_orig = data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["ShipmentServiceOptions"]["InternationalForms"]['cer_orig']
985 nafta_cer_orig = data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["ShipmentServiceOptions"]["InternationalForms"]['nafta_cer_orig']
986 sed = False #data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["ShipmentServiceOptions"]["InternationalForms"]['sed']
987 prod = data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["ShipmentServiceOptions"]["InternationalForms"]['prod']
988
989
990 doc2 = Document()
991 ShipmentConfirmRequest = doc2.createElement("ShipmentConfirmRequest")
992 doc2.appendChild(ShipmentConfirmRequest)
993
994 Request = doc2.createElement("Request")
995 ShipmentConfirmRequest.appendChild(Request)
996
997 RequestAction = doc2.createElement("RequestAction")
998 ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Request"]["RequestAction"])
999 RequestAction.appendChild(ptext)
1000 Request.appendChild(RequestAction)
1001
1002 RequestOption = doc2.createElement("RequestOption")
1003 ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Request"]["RequestOption"])
1004 RequestOption.appendChild(ptext)
1005 Request.appendChild(RequestOption)
1006
1007 TransactionReference = doc2.createElement("TransactionReference")
1008 Request.appendChild(TransactionReference)
1009
1010 CustomerContext = doc2.createElement("CustomerContext")
1011 ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Request"]["TransactionReference"]['CustomerContext'])
1012 CustomerContext.appendChild(ptext)
1013 TransactionReference.appendChild(CustomerContext)
1014
1015 Shipment = doc2.createElement("Shipment")
1016 ShipmentConfirmRequest.appendChild(Shipment)
1017
1018 Description = doc2.createElement("Description")
1019 ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["Description"])
1020 Description.appendChild(ptext)
1021 Shipment.appendChild(Description)
1022 if package_obj.pick_id.with_ret_service:
1023 ReturnService = doc2.createElement("ReturnService")
1024 Shipment.appendChild(ReturnService)
1025
1026
1027 Code = doc2.createElement("Code")
1028 ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["ReturnService"]["Code"])
1029 Code.appendChild(ptext)
1030 ReturnService.appendChild(Code)
1031 #
1032 # DocumentsOnly = doc2.createElement("DocumentsOnly")
1033 # ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["ReturnService"]["DocumentsOnly"])
1034 # DocumentsOnly.appendChild(ptext)
1035 # ReturnService.appendChild(DocumentsOnly)
1036
1037 Shipper = doc2.createElement("Shipper")
1038 Shipment.appendChild(Shipper)
1039
1040 Name = doc2.createElement("Name")
1041 ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["Shipper"]["Name"])
1042 Name.appendChild(ptext)
1043 Shipper.appendChild(Name)
1044
1045 AttentionName = doc2.createElement("AttentionName")
1046 ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["Shipper"]["AttentionName"])
1047 AttentionName.appendChild(ptext)
1048 Shipper.appendChild(AttentionName)
1049
1050 ShipperNumber = doc2.createElement("ShipperNumber")
1051 ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["Shipper"]["ShipperNumber"])
1052 ShipperNumber.appendChild(ptext)
1053 Shipper.appendChild(ShipperNumber)
1054
1055 TaxIdentificationNumber = doc2.createElement("TaxIdentificationNumber")
1056 ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["Shipper"]["TaxIdentificationNumber"])
1057 TaxIdentificationNumber.appendChild(ptext)
1058 Shipper.appendChild(TaxIdentificationNumber)
1059 PhoneNumber = doc2.createElement("PhoneNumber")
1060 ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["Shipper"]["PhoneNumber"])
1061 PhoneNumber.appendChild(ptext)
1062 Shipper.appendChild(PhoneNumber)
1063
1064 FaxNumber = doc2.createElement("FaxNumber")
1065 ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["Shipper"]["FaxNumber"])
1066 FaxNumber.appendChild(ptext)
1067 Shipper.appendChild(FaxNumber)
1068
1069 EMailAddress = doc2.createElement("EMailAddress")
1070 ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["Shipper"]["EMailAddress"])
1071 EMailAddress.appendChild(ptext)
1072 Shipper.appendChild(EMailAddress)
1073
1074 #################address
1075 Address = doc2.createElement("Address")
1076 Shipper.appendChild(Address)
1077
1078 AddressLine1 = doc2.createElement("AddressLine1")
1079 ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["Shipper"]["Address"]["AddressLine1"])
1080 AddressLine1.appendChild(ptext)
1081 Address.appendChild(AddressLine1)
1082
1083 AddressLine2 = doc2.createElement("AddressLine2")
1084 ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["Shipper"]["Address"]["AddressLine2"])
1085 AddressLine2.appendChild(ptext)
1086 Address.appendChild(AddressLine2)
1087
1088 AddressLine3 = doc2.createElement("AddressLine3")
1089 ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["Shipper"]["Address"]["AddressLine3"])
1090 AddressLine3.appendChild(ptext)
1091 Address.appendChild(AddressLine3)
1092
1093 City = doc2.createElement("City")
1094 ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["Shipper"]["Address"]["City"])
1095 City.appendChild(ptext)
1096 Address.appendChild(City)
1097
1098 StateProvinceCode = doc2.createElement("StateProvinceCode")
1099 ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["Shipper"]["Address"]["StateProvinceCode"])
1100 StateProvinceCode.appendChild(ptext)
1101 Address.appendChild(StateProvinceCode)
1102
1103 PostalCode = doc2.createElement("PostalCode")
1104 ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["Shipper"]["Address"]["PostalCode"])
1105 PostalCode.appendChild(ptext)
1106 Address.appendChild(PostalCode)
1107 CountryCode = doc2.createElement("CountryCode")
1108 ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["Shipper"]["Address"]["CountryCode"])
1109 CountryCode.appendChild(ptext)
1110 Address.appendChild(CountryCode)
1111
1112 ShipTo = doc2.createElement("ShipTo")
1113 Shipment.appendChild(ShipTo)
1114 CompanyName = doc2.createElement("CompanyName")
1115 ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["ShipTo"]["CompanyName"])
1116 CompanyName.appendChild(ptext)
1117 ShipTo.appendChild(CompanyName)
1118
1119 AttentionName = doc2.createElement("AttentionName")
1120 ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["ShipTo"]["AttentionName"])
1121 AttentionName.appendChild(ptext)
1122 ShipTo.appendChild(AttentionName)
1123
1124 TaxIdentificationNumber = doc2.createElement("TaxIdentificationNumber")
1125 ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["ShipTo"]["TaxIdentificationNumber"])
1126 TaxIdentificationNumber.appendChild(ptext)
1127 ShipTo.appendChild(TaxIdentificationNumber)
1128
1129 PhoneNumber = doc2.createElement("PhoneNumber")
1130 ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["ShipTo"]["PhoneNumber"])
1131 PhoneNumber.appendChild(ptext)
1132 ShipTo.appendChild(PhoneNumber)
1133
1134 FaxNumber = doc2.createElement("FaxNumber")
1135 ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["ShipTo"]["FaxNumber"])
1136 FaxNumber.appendChild(ptext)
1137 ShipTo.appendChild(FaxNumber)
1138
1139 EMailAddress = doc2.createElement("EMailAddress")
1140 ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["ShipTo"]["EMailAddress"])
1141 EMailAddress.appendChild(ptext)
1142 ShipTo.appendChild(EMailAddress)
1143
1144 LocationID = doc2.createElement("LocationID")
1145 ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["ShipTo"]["LocationID"])
1146 LocationID.appendChild(ptext)
1147 ShipTo.appendChild(LocationID)
1148
1149 Address = doc2.createElement("Address")
1150 ShipTo.appendChild(Address)
1151 AddressLine1 = doc2.createElement("AddressLine1")
1152 ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["ShipTo"]["Address"]["AddressLine1"])
1153 AddressLine1.appendChild(ptext)
1154 Address.appendChild(AddressLine1)
1155
1156 AddressLine2 = doc2.createElement("AddressLine2")
1157 ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["ShipTo"]["Address"]["AddressLine2"])
1158 AddressLine2.appendChild(ptext)
1159 Address.appendChild(AddressLine2)
1160
1161 AddressLine2 = doc2.createElement("AddressLine3")
1162 ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["ShipTo"]["Address"]["AddressLine3"])
1163 AddressLine3.appendChild(ptext)
1164 Address.appendChild(AddressLine3)
1165
1166 City = doc2.createElement("City")
1167 ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["ShipTo"]["Address"]["City"])
1168 City.appendChild(ptext)
1169 Address.appendChild(City)
1170
1171 StateProvinceCode = doc2.createElement("StateProvinceCode")
1172 ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["ShipTo"]["Address"]["StateProvinceCode"])
1173 StateProvinceCode.appendChild(ptext)
1174 Address.appendChild(StateProvinceCode)
1175
1176 PostalCode = doc2.createElement("PostalCode")
1177 ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["ShipTo"]["Address"]["PostalCode"])
1178 PostalCode.appendChild(ptext)
1179 Address.appendChild(PostalCode)
1180
1181 CountryCode = doc2.createElement("CountryCode")
1182 ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["ShipTo"]["Address"]["CountryCode"])
1183 CountryCode.appendChild(ptext)
1184 Address.appendChild(CountryCode)
1185 if package_obj.pick_id.ship_from:
1186 ShipFrom = doc2.createElement("ShipFrom")
1187 Shipment.appendChild(ShipFrom)
1188 CompanyName = doc2.createElement("CompanyName")
1189 ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["ShipFrom"]["CompanyName"])
1190 CompanyName.appendChild(ptext)
1191 ShipFrom.appendChild(CompanyName)
1192
1193 AttentionName = doc2.createElement("AttentionName")
1194 ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["ShipFrom"]["AttentionName"])
1195 AttentionName.appendChild(ptext)
1196 ShipFrom.appendChild(AttentionName)
1197
1198 TaxIdentificationNumber = doc2.createElement("TaxIdentificationNumber")
1199 ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["ShipFrom"]["TaxIdentificationNumber"])
1200 TaxIdentificationNumber.appendChild(ptext)
1201 ShipFrom.appendChild(TaxIdentificationNumber)
1202
1203 PhoneNumber = doc2.createElement("PhoneNumber")
1204 ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["ShipFrom"]["PhoneNumber"])
1205 PhoneNumber.appendChild(ptext)
1206 ShipFrom.appendChild(PhoneNumber)
1207
1208 FaxNumber = doc2.createElement("FaxNumber")
1209 ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["ShipFrom"]["FaxNumber"])
1210 FaxNumber.appendChild(ptext)
1211 ShipFrom.appendChild(FaxNumber)
1212
1213 Address = doc2.createElement("Address")
1214 ShipFrom.appendChild(Address)
1215 AddressLine1 = doc2.createElement("AddressLine1")
1216 ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["ShipFrom"]["Address"]["AddressLine1"])
1217 AddressLine1.appendChild(ptext)
1218 Address.appendChild(AddressLine1)
1219
1220 AddressLine2 = doc2.createElement("AddressLine2")
1221 ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["ShipFrom"]["Address"]["AddressLine2"])
1222 AddressLine2.appendChild(ptext)
1223 Address.appendChild(AddressLine2)
1224
1225 AddressLine3 = doc2.createElement("AddressLine3")
1226 ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["ShipFrom"]["Address"]["AddressLine3"])
1227 AddressLine3.appendChild(ptext)
1228 Address.appendChild(AddressLine3)
1229
1230 City = doc2.createElement("City")
1231 ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["ShipFrom"]["Address"]["City"])
1232 City.appendChild(ptext)
1233 Address.appendChild(City)
1234
1235 StateProvinceCode = doc2.createElement("StateProvinceCode")
1236 ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["ShipFrom"]["Address"]["StateProvinceCode"])
1237 StateProvinceCode.appendChild(ptext)
1238 Address.appendChild(StateProvinceCode)
1239
1240# PostalCode = doc2.createElement("PostalCode")
1241# ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["ShipFrom"]["Address"]["PostalCode"])
1242# PostalCode.appendChild(ptext)
1243# Address.appendChild(PostalCode)
1244
1245 CountryCode = doc2.createElement("CountryCode")
1246 ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["ShipFrom"]["Address"]["CountryCode"])
1247 CountryCode.appendChild(ptext)
1248 Address.appendChild(CountryCode)
1249
1250
1251###################
1252 if comm_inv or nafta_cer_orig:
1253 SoldTo = doc2.createElement("SoldTo")
1254 Shipment.appendChild(SoldTo)
1255# if data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["SoldTo"]["Option"] != ' ':
1256 Option = doc2.createElement("Option")
1257 ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["SoldTo"]["Option"])
1258 Option.appendChild(ptext)
1259 SoldTo.appendChild(Option)
1260
1261 CompanyName = doc2.createElement("CompanyName")
1262 ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["SoldTo"]["CompanyName"])
1263 CompanyName.appendChild(ptext)
1264 SoldTo.appendChild(CompanyName)
1265# else:
1266 CompanyName = doc2.createElement("CompanyName")
1267 ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["SoldTo"]["CompanyName"])
1268 CompanyName.appendChild(ptext)
1269 SoldTo.appendChild(CompanyName)
1270
1271 AttentionName = doc2.createElement("AttentionName")
1272 ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["SoldTo"]["AttentionName"])
1273 AttentionName.appendChild(ptext)
1274 SoldTo.appendChild(AttentionName)
1275
1276 TaxIdentificationNumber = doc2.createElement("TaxIdentificationNumber")
1277 ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["SoldTo"]["TaxIdentificationNumber"])
1278 TaxIdentificationNumber.appendChild(ptext)
1279 SoldTo.appendChild(TaxIdentificationNumber)
1280
1281 PhoneNumber = doc2.createElement("PhoneNumber")
1282 ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["SoldTo"]["PhoneNumber"])
1283 PhoneNumber.appendChild(ptext)
1284 SoldTo.appendChild(PhoneNumber)
1285
1286
1287 Address = doc2.createElement("Address")
1288 SoldTo.appendChild(Address)
1289 AddressLine1 = doc2.createElement("AddressLine1")
1290 ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["SoldTo"]["Address"]["AddressLine1"])
1291 AddressLine1.appendChild(ptext)
1292 Address.appendChild(AddressLine1)
1293
1294 AddressLine2 = doc2.createElement("AddressLine2")
1295 ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["SoldTo"]["Address"]["AddressLine2"])
1296 AddressLine2.appendChild(ptext)
1297 Address.appendChild(AddressLine2)
1298
1299
1300 City = doc2.createElement("City")
1301 ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["SoldTo"]["Address"]["City"])
1302 City.appendChild(ptext)
1303 Address.appendChild(City)
1304
1305 StateProvinceCode = doc2.createElement("StateProvinceCode")
1306 ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["SoldTo"]["Address"]["StateProvinceCode"])
1307 StateProvinceCode.appendChild(ptext)
1308 Address.appendChild(StateProvinceCode)
1309
1310 PostalCode = doc2.createElement("PostalCode")
1311 ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["SoldTo"]["Address"]["PostalCode"])
1312 PostalCode.appendChild(ptext)
1313 Address.appendChild(PostalCode)
1314
1315 CountryCode = doc2.createElement("CountryCode")
1316 ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["SoldTo"]["Address"]["CountryCode"])
1317 CountryCode.appendChild(ptext)
1318 Address.appendChild(CountryCode)
1319
1320#########################
1321 PaymentInformation = doc2.createElement("PaymentInformation")
1322 Shipment.appendChild(PaymentInformation)
1323 Prepaid = doc2.createElement("Prepaid")
1324 PaymentInformation.appendChild(Prepaid)
1325
1326 BillShipper = doc2.createElement("BillShipper")
1327 Prepaid.appendChild(BillShipper)
1328
1329 AccountNumber = doc2.createElement("AccountNumber")
1330 ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["PaymentInformation"]["Prepaid"]["BillShipper"]["AccountNumber"])
1331 AccountNumber.appendChild(ptext)
1332 BillShipper.appendChild(AccountNumber)
1333
1334 # CreditCard = doc2.createElement("CreditCard")
1335 # BillShipper.appendChild(CreditCard)
1336 # Type = doc2.createElement("Type")
1337 # ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["PaymentInformation"]["Prepaid"]["BillShipper"]["CreditCard"]["Type"])
1338 # Type.appendChild(ptext)
1339 # CreditCard.appendChild(Type)
1340 #
1341 # ExpirationDate = doc2.createElement("ExpirationDate")
1342 # ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["PaymentInformation"]["Prepaid"]["BillShipper"]["CreditCard"]["ExpirationDate"])
1343 # ExpirationDate.appendChild(ptext)
1344 # CreditCard.appendChild(ExpirationDate)
1345 #
1346 # Number = doc2.createElement("Number")
1347 # ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["PaymentInformation"]["Prepaid"]["BillShipper"]["CreditCard"]["Number"])
1348 # Number.appendChild(ptext)
1349 # CreditCard.appendChild(Number)
1350 #
1351 # SecurityCode = doc2.createElement("SecurityCode")
1352 # ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["PaymentInformation"]["Prepaid"]["BillShipper"]["CreditCard"]["SecurityCode"])
1353 # SecurityCode.appendChild(ptext)
1354 # CreditCard.appendChild(SecurityCode)
1355 #
1356 #
1357 # Address = doc2.createElement("Address")
1358 # CreditCard.appendChild(Address)
1359 # AddressLine1 = doc2.createElement("AddressLine1")
1360 # ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["PaymentInformation"]["Prepaid"]["BillShipper"]["CreditCard"]["Address"]["AddressLine1"])
1361 # AddressLine1.appendChild(ptext)
1362 # Address.appendChild(AddressLine1)
1363 #
1364 # AddressLine2 = doc2.createElement("AddressLine2")
1365 # ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["PaymentInformation"]["Prepaid"]["BillShipper"]["CreditCard"]["Address"]["AddressLine2"])
1366 # AddressLine2.appendChild(ptext)
1367 # Address.appendChild(AddressLine2)
1368 #
1369 # AddressLine3 = doc2.createElement("AddressLine3")
1370 # ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["PaymentInformation"]["Prepaid"]["BillShipper"]["CreditCard"]["Address"]["AddressLine3"])
1371 # AddressLine3.appendChild(ptext)
1372 # Address.appendChild(AddressLine3)
1373 #
1374 #
1375 # City = doc2.createElement("City")
1376 # ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["PaymentInformation"]["Prepaid"]["BillShipper"]["CreditCard"]["Address"]["City"])
1377 # City.appendChild(ptext)
1378 # Address.appendChild(City)
1379 #
1380 # StateProvinceCode = doc2.createElement("StateProvinceCode")
1381 # ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["PaymentInformation"]["Prepaid"]["BillShipper"]["CreditCard"]["Address"]["StateProvinceCode"])
1382 # StateProvinceCode.appendChild(ptext)
1383 # Address.appendChild(StateProvinceCode)
1384 #
1385 # PostalCode = doc2.createElement("PostalCode")
1386 # ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["PaymentInformation"]["Prepaid"]["BillShipper"]["CreditCard"]["Address"]["PostalCode"])
1387 # PostalCode.appendChild(ptext)
1388 # Address.appendChild(PostalCode)
1389 #
1390 # CountryCode = doc2.createElement("CountryCode")
1391 # ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["PaymentInformation"]["Prepaid"]["BillShipper"]["CreditCard"]["Address"]["CountryCode"])
1392 # PostalCode.appendChild(ptext)
1393 # Address.appendChild(CountryCode)
1394
1395
1396
1397
1398 # BillThirdParty = doc2.createElement("BillThirdParty")
1399 # PaymentInformation.appendChild(BillThirdParty)
1400 # BillThirdPartyShipper = doc2.createElement("BillThirdPartyShipper")
1401 # BillThirdParty.appendChild(BillThirdPartyShipper)
1402 #
1403 # AccountNumber = doc2.createElement("AccountNumber")
1404 # ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["PaymentInformation"]["BillThirdParty"]['BillThirdPartyShipper']['AccountNumber'])
1405 # AccountNumber.appendChild(ptext)
1406 # BillThirdPartyShipper.appendChild(AccountNumber)
1407 #
1408 # ThirdParty = doc2.createElement("ThirdParty")
1409 # BillThirdPartyShipper.appendChild(ThirdParty)
1410 # Address = doc2.createElement("Address")
1411 # ThirdParty.appendChild(Address)
1412 #
1413 # PostalCode = doc2.createElement("PostalCode")
1414 # ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["PaymentInformation"]["BillThirdParty"]['BillThirdPartyShipper']['ThirdParty']['Address']['PostalCode'])
1415 # PostalCode.appendChild(ptext)
1416 # Address.appendChild(PostalCode)
1417 #
1418 # CountryCode = doc2.createElement("CountryCode")
1419 # ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["PaymentInformation"]["BillThirdParty"]['BillThirdPartyShipper']['ThirdParty']['Address']['CountryCode'])
1420 # CountryCode.appendChild(ptext)
1421 # Address.appendChild(CountryCode)
1422
1423
1424
1425 # FreightCollect = doc2.createElement("FreightCollect")
1426 # PaymentInformation.appendChild(FreightCollect)
1427 # BillReceiver = doc2.createElement("BillReceiver")
1428 # FreightCollect.appendChild(BillReceiver)
1429 # AccountNumber = doc2.createElement("AccountNumber")
1430 # ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["PaymentInformation"]["FreightCollect"]["BillReceiver"]["AccountNumber"])
1431 # AccountNumber.appendChild(ptext)
1432 # BillReceiver.appendChild(AccountNumber)
1433 #
1434 # Address = doc2.createElement("Address")
1435 # BillReceiver.appendChild(Address)
1436 # PostalCode = doc2.createElement("PostalCode")
1437 # ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["PaymentInformation"]["FreightCollect"]["BillReceiver"]["Address"]["PostalCode"])
1438 # AccountNumber.appendChild(ptext)
1439 # Address.appendChild(PostalCode)
1440
1441 # ConsigneeBilled = doc2.createElement("ConsigneeBilled")
1442 # ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["PaymentInformation"]["ConsigneeBilled"])
1443 # ConsigneeBilled.appendChild(ptext)
1444 # PaymentInformation.appendChild(ConsigneeBilled)
1445
1446
1447
1448
1449 # ItemizedPaymentInformation = doc2.createElement("ItemizedPaymentInformation")
1450 # Shipment.appendChild(ItemizedPaymentInformation)
1451 # ShipmentCharge = doc2.createElement("ShipmentCharge")
1452 # ItemizedPaymentInformation.appendChild(ShipmentCharge)
1453 # Type = doc2.createElement("Type")
1454 # ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["ItemizedPaymentInformation"]["ShipmentCharge"]["Type"])
1455 # Type.appendChild(ptext)
1456 # ShipmentCharge.appendChild(Type)
1457 #
1458 # BillShipper = doc2.createElement("BillShipper")
1459 # ShipmentCharge.appendChild(BillShipper)
1460 #
1461 # AccountNumber = doc2.createElement("AccountNumber")
1462 # ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["ItemizedPaymentInformation"]["ShipmentCharge"]["BillShipper"]["AccountNumber"])
1463 # AccountNumber.appendChild(ptext)
1464 # BillShipper.appendChild(AccountNumber)
1465 #
1466 # CreditCard = doc2.createElement("CreditCard")
1467 # BillShipper.appendChild(CreditCard)
1468 #
1469 # Type = doc2.createElement("Type")
1470 # ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["ItemizedPaymentInformation"]["ShipmentCharge"]["BillShipper"]["CreditCard"]["Type"])
1471 # Type.appendChild(ptext)
1472 # CreditCard.appendChild(Type)
1473 #
1474 # ExpirationDate = doc2.createElement("ExpirationDate")
1475 # ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["ItemizedPaymentInformation"]["ShipmentCharge"]["BillShipper"]["CreditCard"]["ExpirationDate"])
1476 # ExpirationDate.appendChild(ptext)
1477 # CreditCard.appendChild(ExpirationDate)
1478 #
1479 # SecurityCode = doc2.createElement("SecurityCode")
1480 # ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["ItemizedPaymentInformation"]["ShipmentCharge"]["BillShipper"]["CreditCard"]["SecurityCode"])
1481 # SecurityCode.appendChild(ptext)
1482 # CreditCard.appendChild(SecurityCode)
1483 #
1484 # Address = doc2.createElement("Address")
1485 # CreditCard.appendChild(Address)
1486 # AddressLine1 = doc2.createElement("AddressLine1")
1487 # ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["ItemizedPaymentInformation"]["ShipmentCharge"]["BillShipper"]['CreditCard']["Address"]["AddressLine1"])
1488 # AddressLine1.appendChild(ptext)
1489 # Address.appendChild(AddressLine1)
1490 #
1491 # AddressLine2 = doc2.createElement("AddressLine2")
1492 # ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["ItemizedPaymentInformation"]["ShipmentCharge"]["BillShipper"]['CreditCard']["Address"]["AddressLine2"])
1493 # AddressLine2.appendChild(ptext)
1494 # Address.appendChild(AddressLine2)
1495 #
1496 # AddressLine3 = doc2.createElement("AddressLine3")
1497 # ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["ItemizedPaymentInformation"]["ShipmentCharge"]["BillShipper"]['CreditCard']["Address"]["AddressLine3"])
1498 # AddressLine3.appendChild(ptext)
1499 # Address.appendChild(AddressLine3)
1500 #
1501 # City = doc2.createElement("City")
1502 # ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["ItemizedPaymentInformation"]["ShipmentCharge"]["BillShipper"]['CreditCard']["Address"]["City"])
1503 # City.appendChild(ptext)
1504 # Address.appendChild(City)
1505 #
1506 # StateProvinceCode = doc2.createElement("StateProvinceCode")
1507 # ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["ItemizedPaymentInformation"]["ShipmentCharge"]["BillShipper"]['CreditCard']["Address"]["StateProvinceCode"])
1508 # StateProvinceCode.appendChild(ptext)
1509 # Address.appendChild(StateProvinceCode)
1510 #
1511 # PostalCode = doc2.createElement("PostalCode")
1512 # ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["ItemizedPaymentInformation"]["ShipmentCharge"]["BillShipper"]['CreditCard']["Address"]["PostalCode"])
1513 # PostalCode.appendChild(ptext)
1514 # Address.appendChild(PostalCode)
1515 #
1516 # CountryCode = doc2.createElement("CountryCode")
1517 # ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["ItemizedPaymentInformation"]["ShipmentCharge"]["BillShipper"]['CreditCard']["Address"]["CountryCode"])
1518 # CountryCode.appendChild(ptext)
1519 # Address.appendChild(CountryCode)
1520 #
1521 # BillReceiver = doc2.createElement("BillReceiver")
1522 # ShipmentCharge.appendChild(BillReceiver)
1523 #
1524 # AccountNumber = doc2.createElement("AccountNumber")
1525 # ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["ItemizedPaymentInformation"]["ShipmentCharge"]["BillReceiver"]["AccountNumber"])
1526 # AccountNumber.appendChild(ptext)
1527 # BillReceiver.appendChild(AccountNumber)
1528 #
1529 # Address = doc2.createElement("Address")
1530 # BillReceiver.appendChild(Address)
1531 # PostalCode = doc2.createElement("PostalCode")
1532 # ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["ItemizedPaymentInformation"]["ShipmentCharge"]["BillReceiver"]["Address"]["PostalCode"])
1533 # PostalCode.appendChild(ptext)
1534 # Address.appendChild(PostalCode)
1535 #
1536 #
1537 # BillThirdParty = doc2.createElement("BillThirdParty")
1538 # ShipmentCharge.appendChild(BillThirdParty)
1539 # BillThirdPartyShipper = doc2.createElement("BillThirdPartyShipper")
1540 # BillThirdParty.appendChild(BillThirdPartyShipper)
1541 #
1542 # AccountNumber = doc2.createElement("AccountNumber")
1543 # ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["ItemizedPaymentInformation"]["ShipmentCharge"]["BillThirdParty"]["BillThirdPartyShipper"]["AccountNumber"])
1544 # AccountNumber.appendChild(ptext)
1545 # BillThirdPartyShipper.appendChild(AccountNumber)
1546 #
1547 # ThirdParty = doc2.createElement("ThirdParty")
1548 # BillThirdPartyShipper.appendChild(ThirdParty)
1549 # Address = doc2.createElement("Address")
1550 # ThirdParty.appendChild(Address)
1551 # PostalCode = doc2.createElement("PostalCode")
1552 # ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["ItemizedPaymentInformation"]["ShipmentCharge"]["BillThirdParty"]["BillThirdPartyShipper"]["ThirdParty"]["Address"]["PostalCode"])
1553 # PostalCode.appendChild(ptext)
1554 # Address.appendChild(PostalCode)
1555 #
1556 # CountryCode = doc2.createElement("CountryCode")
1557 # ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["ItemizedPaymentInformation"]["ShipmentCharge"]["BillThirdParty"]["BillThirdPartyShipper"]["ThirdParty"]["Address"]["CountryCode"])
1558 # CountryCode.appendChild(ptext)
1559 # Address.appendChild(CountryCode)
1560 #
1561 #
1562 # BillThirdPartyConsignee = doc2.createElement("BillThirdPartyConsignee")
1563 # BillThirdParty.appendChild(BillThirdPartyConsignee)
1564 #
1565 # AccountNumber = doc2.createElement("AccountNumber")
1566 # ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["ItemizedPaymentInformation"]["ShipmentCharge"]["BillThirdParty"]["BillThirdPartyConsignee"]["AccountNumber"])
1567 # AccountNumber.appendChild(ptext)
1568 # BillThirdPartyConsignee.appendChild(AccountNumber)
1569 #
1570 # ThirdParty = doc2.createElement("ThirdParty")
1571 # BillThirdPartyConsignee.appendChild(ThirdParty)
1572 # Address = doc2.createElement("Address")
1573 # ThirdParty.appendChild(Address)
1574 # PostalCode = doc2.createElement("PostalCode")
1575 # ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["ItemizedPaymentInformation"]["ShipmentCharge"]["BillThirdParty"]["BillThirdPartyConsignee"]["ThirdParty"]["Address"]["PostalCode"])
1576 # PostalCode.appendChild(ptext)
1577 # Address.appendChild(PostalCode)
1578 #
1579 # CountryCode = doc2.createElement("CountryCode")
1580 # ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["ItemizedPaymentInformation"]["ShipmentCharge"]["BillThirdParty"]["BillThirdPartyConsignee"]["ThirdParty"]["Address"]["CountryCode"])
1581 # CountryCode.appendChild(ptext)
1582 # Address.appendChild(CountryCode)
1583 #
1584 # ConsigneeBilled = doc2.createElement("ConsigneeBilled")
1585 # ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["ItemizedPaymentInformation"]["ShipmentCharge"]["ConsigneeBilled"])
1586 # ConsigneeBilled.appendChild(ptext)
1587 # ShipmentCharge.appendChild(ConsigneeBilled)
1588 #
1589 # SplitDutyVATIndicator = doc2.createElement("SplitDutyVATIndicator")
1590 # ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["ItemizedPaymentInformation"]["SplitDutyVATIndicator"])
1591 # SplitDutyVATIndicator.appendChild(ptext)
1592 # ItemizedPaymentInformation.appendChild(SplitDutyVATIndicator)
1593
1594 GoodsNotInFreeCirculationIndicator = doc2.createElement("GoodsNotInFreeCirculationIndicator")
1595 # ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["GoodsNotInFreeCirculationIndicator"])
1596 # GoodsNotInFreeCirculationIndicator.appendChild(ptext)
1597 Shipment.appendChild(GoodsNotInFreeCirculationIndicator)
1598
1599 RateInformation = doc2.createElement("RateInformation")
1600 Shipment.appendChild(RateInformation)
1601 NegotiatedRatesIndicator = doc2.createElement("NegotiatedRatesIndicator")
1602 # ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["RateInformation"]["NegotiatedRatesIndicator"])
1603 # NegotiatedRatesIndicator.appendChild(ptext)
1604 RateInformation.appendChild(NegotiatedRatesIndicator)
1605
1606 # MovementReferenceNumber = doc2.createElement("MovementReferenceNumber")
1607 # ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["MovementReferenceNumber"])
1608 # MovementReferenceNumber.appendChild(ptext)
1609 # Shipment.appendChild(MovementReferenceNumber)
1610
1611 # ReferenceNumber = doc2.createElement("ReferenceNumber")
1612 # Shipment.appendChild(ReferenceNumber)
1613 # BarCodeIndicator = doc2.createElement("BarCodeIndicator")
1614 # ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["ReferenceNumber"]["BarCodeIndicator"])
1615 # BarCodeIndicator.appendChild(ptext)
1616 # ReferenceNumber.appendChild(BarCodeIndicator)
1617 #
1618 # Code = doc2.createElement("Code")
1619 # ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["ReferenceNumber"]["Code"])
1620 # Code.appendChild(ptext)
1621 # ReferenceNumber.appendChild(Code)
1622 #
1623 # Value = doc2.createElement("Value")
1624 # ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["ReferenceNumber"]["Value"])
1625 # Value.appendChild(ptext)
1626 # ReferenceNumber.appendChild(Value)
1627
1628 Service = doc2.createElement("Service")
1629 Shipment.appendChild(Service)
1630 Code = doc2.createElement("Code")
1631 ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["Service"]["Code"])
1632 Code.appendChild(ptext)
1633 Service.appendChild(Code)
1634 Description = doc2.createElement("Description")
1635 ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["Service"]["Description"])
1636 Description.appendChild(ptext)
1637 Service.appendChild(Description)
1638
1639 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'):
1640 InvoiceLineTotal = doc2.createElement("InvoiceLineTotal")
1641 Shipment.appendChild(InvoiceLineTotal)
1642
1643 # CurrencyCode = doc2.createElement("CurrencyCode")
1644 # ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["InvoiceLineTotal"]["CurrencyCode"])
1645 # CurrencyCode.appendChild(ptext)
1646 # InvoiceLineTotal.appendChild(CurrencyCode)
1647
1648 MonetaryValue = doc2.createElement("MonetaryValue")
1649 ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["InvoiceLineTotal"]["MonetaryValue"])
1650 MonetaryValue.appendChild(ptext)
1651 InvoiceLineTotal.appendChild(MonetaryValue)
1652
1653
1654 ShipmentServiceOptions = doc2.createElement("ShipmentServiceOptions")
1655 Shipment.appendChild(ShipmentServiceOptions)
1656 if package_obj.pick_id.sat_delivery:
1657 SaturdayDelivery = doc2.createElement("SaturdayDelivery")
1658 # ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["ShipmentServiceOptions"]["SaturdayDelivery"])
1659 # SaturdayDelivery.appendChild(ptext)
1660 ShipmentServiceOptions.appendChild(SaturdayDelivery)
1661 # COD = doc2.createElement("COD")
1662 # ShipmentServiceOptions.appendChild(COD)
1663 # CODCode = doc2.createElement("CODCode")
1664 # ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["ShipmentServiceOptions"]["COD"]["CODCode"])
1665 # CODCode.appendChild(ptext)
1666 # COD.appendChild(CODCode)
1667 #
1668 # CODFundsCode = doc2.createElement("CODFundsCode")
1669 # ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["ShipmentServiceOptions"]["COD"]["CODFundsCode"])
1670 # CODFundsCode.appendChild(ptext)
1671 # COD.appendChild(CODFundsCode)
1672 #
1673 # CODAmount = doc2.createElement("CODAmount")
1674 # COD.appendChild(CODAmount)
1675 # CurrencyCode = doc2.createElement("CurrencyCode")
1676 # ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["ShipmentServiceOptions"]["COD"]["CODAmount"]["CurrencyCode"])
1677 # CurrencyCode.appendChild(ptext)
1678 # CODAmount.appendChild(CurrencyCode)
1679 #
1680 # MonetaryValue = doc2.createElement("MonetaryValue")
1681 # ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["ShipmentServiceOptions"]["COD"]["CODAmount"]["MonetaryValue"])
1682 # MonetaryValue.appendChild(ptext)
1683 # CODAmount.appendChild(MonetaryValue)
1684
1685 Notification_count = len(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["ShipmentServiceOptions"]["Notification"])
1686 for i in range (0,Notification_count):
1687 Notification = doc2.createElement("Notification")
1688 ShipmentServiceOptions.appendChild(Notification)
1689 NotificationCode = doc2.createElement("NotificationCode")
1690 ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["ShipmentServiceOptions"]["Notification"][i]["NotificationCode"])
1691 NotificationCode.appendChild(ptext)
1692 Notification.appendChild(NotificationCode)
1693 EMailMessage = doc2.createElement("EMailMessage")
1694 Notification.appendChild(EMailMessage)
1695 UndeliverableEMailAddress = doc2.createElement("UndeliverableEMailAddress")
1696 ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["ShipmentServiceOptions"]["Notification"][i]["EMailMessage"]["UndeliverableEMailAddress"])
1697 UndeliverableEMailAddress.appendChild(ptext)
1698 EMailMessage.appendChild(UndeliverableEMailAddress)
1699
1700 EMailAddress = doc2.createElement("EMailAddress")
1701 ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["ShipmentServiceOptions"]["Notification"][i]["EMailMessage"]["EMailAddress"])
1702 EMailAddress.appendChild(ptext)
1703 EMailMessage.appendChild(EMailAddress)
1704
1705 FromEMailAddress = doc2.createElement("FromEMailAddress")
1706 ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["ShipmentServiceOptions"]["Notification"][i]["EMailMessage"]["FromEMailAddress"])
1707 FromEMailAddress.appendChild(ptext)
1708 EMailMessage.appendChild(FromEMailAddress)
1709
1710 FromName = doc2.createElement("FromName")
1711 ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["ShipmentServiceOptions"]["Notification"][i]["EMailMessage"]["FromName"])
1712 FromName.appendChild(ptext)
1713 EMailMessage.appendChild(FromName)
1714
1715 Memo = doc2.createElement("Memo")
1716 ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["ShipmentServiceOptions"]["Notification"][i]["EMailMessage"]["Memo"])
1717 Memo.appendChild(ptext)
1718 EMailMessage.appendChild(Memo)
1719
1720 Subject = doc2.createElement("Subject")
1721 ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["ShipmentServiceOptions"]["Notification"][i]["EMailMessage"]["Subject"])
1722 Subject.appendChild(ptext)
1723 EMailMessage.appendChild(Subject)
1724
1725 SubjectCode = doc2.createElement("SubjectCode")
1726 ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["ShipmentServiceOptions"]["Notification"][i]["EMailMessage"]["SubjectCode"])
1727 SubjectCode.appendChild(ptext)
1728 EMailMessage.appendChild(SubjectCode)
1729 ##//////////////////////end for loop in code
1730 if package_obj.pick_id.with_ret_service:
1731 LabelDelivery = doc2.createElement("LabelDelivery")
1732 ShipmentServiceOptions.appendChild(LabelDelivery)
1733 LabelLinkIndicator = doc2.createElement("LabelLinkIndicator")
1734 # ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["ShipmentServiceOptions"]["LabelDelivery"]["LabelLinkIndicator"])
1735 # LabelLinkIndicator.appendChild(ptext)
1736 LabelDelivery.appendChild(LabelLinkIndicator)
1737 # EMailMessage = doc2.createElement("EMailMessage")
1738 # LabelDelivery.appendChild(EMailMessage)
1739 # UndeliverableEMailAddress = doc2.createElement("UndeliverableEMailAddress")
1740 # ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["ShipmentServiceOptions"]["LabelDelivery"]["EMailMessage"]["UndeliverableEMailAddress"])
1741 # UndeliverableEMailAddress.appendChild(ptext)
1742 # EMailMessage.appendChild(UndeliverableEMailAddress)
1743 #
1744 #
1745 # EMailAddress = doc2.createElement("EMailAddress")
1746 # ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["ShipmentServiceOptions"]["LabelDelivery"]["EMailMessage"]["EMailAddress"])
1747 # EMailAddress.appendChild(ptext)
1748 # EMailMessage.appendChild(EMailAddress)
1749 #
1750 # FromEMailAddress = doc2.createElement("FromEMailAddress")
1751 # ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["ShipmentServiceOptions"]["LabelDelivery"]["EMailMessage"]["FromEMailAddress"])
1752 # FromEMailAddress.appendChild(ptext)
1753 # EMailMessage.appendChild(FromEMailAddress)
1754 #
1755 # FromName = doc2.createElement("FromName")
1756 # ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["ShipmentServiceOptions"]["LabelDelivery"]["EMailMessage"]["FromName"])
1757 # FromName.appendChild(ptext)
1758 # EMailMessage.appendChild(FromName)
1759 #
1760 # Memo = doc2.createElement("Memo")
1761 # ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["ShipmentServiceOptions"]["LabelDelivery"]["EMailMessage"]["Memo"])
1762 # Memo.appendChild(ptext)
1763 # EMailMessage.appendChild(Memo)
1764 #
1765 # Subject = doc2.createElement("Subject")
1766 # ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["ShipmentServiceOptions"]["LabelDelivery"]["EMailMessage"]["Subject"])
1767 # Subject.appendChild(ptext)
1768 # EMailMessage.appendChild(Subject)
1769 #
1770 # SubjectCode = doc2.createElement("SubjectCode")
1771 # ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["ShipmentServiceOptions"]["LabelDelivery"]["EMailMessage"]["SubjectCode"])
1772 # SubjectCode.appendChild(ptext)
1773 # EMailMessage.appendChild(SubjectCode)
1774
1775
1776
1777 if comm_inv or cer_orig or nafta_cer_orig or sed:
1778 InternationalForms = doc2.createElement("InternationalForms")
1779 ShipmentServiceOptions.appendChild(InternationalForms)
1780
1781# if cer_orig or nafta_cer_orig or sed:
1782# AdditionalDocumentIndicator = doc2.createElement("AdditionalDocumentIndicator")
1783# InternationalForms.appendChild(AdditionalDocumentIndicator)
1784
1785 if comm_inv:
1786 FormType = doc2.createElement("FormType")
1787 ptext = doc1.createTextNode(comm_inv['FormType'])
1788 FormType.appendChild(ptext)
1789 InternationalForms.appendChild(FormType)
1790 if cer_orig:
1791 FormType = doc2.createElement("FormType")
1792 ptext = doc1.createTextNode(cer_orig['FormType'])
1793 FormType.appendChild(ptext)
1794 InternationalForms.appendChild(FormType)
1795 if nafta_cer_orig:
1796 FormType = doc2.createElement("FormType")
1797 ptext = doc1.createTextNode(nafta_cer_orig['FormType'])
1798 FormType.appendChild(ptext)
1799 InternationalForms.appendChild(FormType)
1800# if sed:
1801# FormType = doc2.createElement("FormType")
1802# ptext = doc1.createTextNode(sed['FormType'])
1803# FormType.appendChild(ptext)
1804# InternationalForms.appendChild(FormType)
1805#
1806# SEDFilingOption = doc2.createElement("SEDFilingOption")
1807# ptext = doc1.createTextNode(sed['SEDFilingOption'])
1808# SEDFilingOption.appendChild(ptext)
1809# InternationalForms.appendChild(SEDFilingOption)
1810
1811 if sed or nafta_cer_orig:
1812 Contacts = doc2.createElement("Contacts")
1813 InternationalForms.appendChild(Contacts)
1814# if sed.get("ForwardAgent",False):
1815# ForwardAgent = doc2.createElement("ForwardAgent")
1816# Contacts.appendChild(ForwardAgent)
1817#
1818# CompanyName = doc2.createElement("CompanyName")
1819# ptext = doc1.createTextNode(sed['Contacts']['ForwardAgent']['CompanyName'])
1820# CompanyName.appendChild(ptext)
1821# ForwardAgent.appendChild(CompanyName)
1822#
1823# TaxIdentificationNumber = doc2.createElement("TaxIdentificationNumber")
1824# ptext = doc1.createTextNode(sed['Contacts']['ForwardAgent']["TaxIdentificationNumber"])
1825# TaxIdentificationNumber.appendChild(ptext)
1826# ForwardAgent.appendChild(TaxIdentificationNumber)
1827#
1828# Address = doc2.createElement("Address")
1829# ForwardAgent.appendChild(Address)
1830#
1831# AddressLine1 = doc2.createElement("AddressLine1")
1832# ptext = doc1.createTextNode(sed['Contacts']['ForwardAgent']['Address']['AddressLine1'])
1833# AddressLine1.appendChild(ptext)
1834# Address.appendChild(AddressLine1)
1835#
1836# AddressLine2 = doc2.createElement("AddressLine2")
1837# ptext = doc1.createTextNode(sed['Contacts']['ForwardAgent']['Address']['AddressLine2'])
1838# AddressLine2.appendChild(ptext)
1839# Address.appendChild(AddressLine2)
1840#
1841# City = doc2.createElement("City")
1842# ptext = doc1.createTextNode(sed['Contacts']['ForwardAgent']['Address']['City'])
1843# City.appendChild(ptext)
1844# Address.appendChild(City)
1845#
1846# StateProvinceCode = doc2.createElement("StateProvinceCode")
1847# ptext = doc1.createTextNode(sed['Contacts']['ForwardAgent']['Address']['StateProvinceCode'])
1848# StateProvinceCode.appendChild(ptext)
1849# Address.appendChild(StateProvinceCode)
1850#
1851# PostalCode = doc2.createElement("PostalCode")
1852# ptext = doc1.createTextNode(sed['Contacts']['ForwardAgent']['Address']['PostalCode'])
1853# PostalCode.appendChild(ptext)
1854# Address.appendChild(PostalCode)
1855#
1856# CountryCode = doc2.createElement("CountryCode")
1857# ptext = doc1.createTextNode(sed['Contacts']['ForwardAgent']['Address']['CountryCode'])
1858# CountryCode.appendChild(ptext)
1859# Address.appendChild(CountryCode)
1860# if sed.get("UltimateConsignee",False):
1861#
1862# UltimateConsignee = doc2.createElement("UltimateConsignee")
1863# Contacts.appendChild(UltimateConsignee)
1864#
1865# CompanyName = doc2.createElement("CompanyName")
1866# ptext = doc1.createTextNode(sed["Contacts"]['UltimateConsignee']['CompanyName'])
1867# CompanyName.appendChild(ptext)
1868# UltimateConsignee.appendChild(CompanyName)
1869#
1870# Address = doc2.createElement("Address")
1871# UltimateConsignee.appendChild(Address)
1872#
1873# AddressLine1 = doc2.createElement("AddressLine1")
1874# ptext = doc1.createTextNode(sed["Contacts"]['UltimateConsignee']['Address']['AddressLine1'])
1875# AddressLine1.appendChild(ptext)
1876# Address.appendChild(AddressLine1)
1877#
1878# AddressLine2 = doc2.createElement("AddressLine2")
1879# ptext = doc1.createTextNode(sed["Contacts"]['UltimateConsignee']['Address']['AddressLine2'])
1880# AddressLine2.appendChild(ptext)
1881# Address.appendChild(AddressLine2)
1882#
1883# City = doc2.createElement("City")
1884# ptext = doc1.createTextNode(sed["Contacts"]['UltimateConsignee']['Address']['City'])
1885# City.appendChild(ptext)
1886# Address.appendChild(City)
1887#
1888# StateProvinceCode = doc2.createElement("StateProvinceCode")
1889# ptext = doc1.createTextNode(sed["Contacts"]['UltimateConsignee']['Address']['StateProvinceCode'])
1890# StateProvinceCode.appendChild(ptext)
1891# Address.appendChild(StateProvinceCode)
1892#
1893# PostalCode = doc2.createElement("PostalCode")
1894# ptext = doc1.createTextNode(sed["Contacts"]['UltimateConsignee']['Address']['PostalCode'])
1895# PostalCode.appendChild(ptext)
1896# Address.appendChild(PostalCode)
1897#
1898# CountryCode = doc2.createElement("CountryCode")
1899# ptext = doc1.createTextNode(sed["Contacts"]['UltimateConsignee']['Address']['CountryCode'])
1900# CountryCode.appendChild(ptext)
1901# Address.appendChild(CountryCode)
1902#
1903# if sed.get("IntermediateConsignee",False):
1904# IntermediateConsignee = doc2.createElement("IntermediateConsignee")
1905# Contacts.appendChild(IntermediateConsignee)
1906#
1907#
1908#
1909# CompanyName = doc2.createElement("CompanyName")
1910# ptext = doc1.createTextNode(sed["Contacts"]['IntermediateConsignee']['CompanyName'])
1911# CompanyName.appendChild(ptext)
1912# IntermediateConsignee.appendChild(CompanyName)
1913#
1914#
1915#
1916# Address = doc2.createElement("Address")
1917# IntermediateConsignee.appendChild(Address)
1918#
1919# AddressLine1 = doc2.createElement("AddressLine1")
1920# ptext = doc1.createTextNode(sed["Contacts"]['IntermediateConsignee']['Address']['AddressLine1'])
1921# AddressLine1.appendChild(ptext)
1922# Address.appendChild(AddressLine1)
1923#
1924# AddressLine2 = doc2.createElement("AddressLine2")
1925# ptext = doc1.createTextNode(sed["Contacts"]['IntermediateConsignee']['Address']['AddressLine2'])
1926# AddressLine2.appendChild(ptext)
1927# Address.appendChild(AddressLine2)
1928#
1929# City = doc2.createElement("City")
1930# ptext = doc1.createTextNode(sed["Contacts"]['IntermediateConsignee']['Address']['City'])
1931# City.appendChild(ptext)
1932# Address.appendChild(City)
1933#
1934# StateProvinceCode = doc2.createElement("StateProvinceCode")
1935# ptext = doc1.createTextNode(sed["Contacts"]['IntermediateConsignee']['Address']['StateProvinceCode'])
1936# StateProvinceCode.appendChild(ptext)
1937# Address.appendChild(StateProvinceCode)
1938#
1939# PostalCode = doc2.createElement("PostalCode")
1940# ptext = doc1.createTextNode(sed["Contacts"]['IntermediateConsignee']['Address']['PostalCode'])
1941# PostalCode.appendChild(ptext)
1942# Address.appendChild(PostalCode)
1943#
1944# CountryCode = doc2.createElement("CountryCode")
1945# ptext = doc1.createTextNode(sed["Contacts"]['IntermediateConsignee']['Address']['CountryCode'])
1946# CountryCode.appendChild(ptext)
1947# Address.appendChild(CountryCode)
1948 if nafta_cer_orig and nafta_cer_orig["Contacts"].get("Producer"):
1949 Producer = doc2.createElement("Producer")
1950 Contacts.appendChild(Producer)
1951 if nafta_cer_orig["Contacts"]['Producer'].get('Option') != ' ':
1952 Option = doc2.createElement("Option")
1953 ptext = doc1.createTextNode(nafta_cer_orig["Contacts"]['Producer']['Option'])
1954 Option.appendChild(ptext)
1955 Producer.appendChild(Option)
1956 else:
1957 CompanyName = doc2.createElement("CompanyName")
1958 ptext = doc1.createTextNode(nafta_cer_orig["Contacts"]['Producer']['CompanyName'])
1959 CompanyName.appendChild(ptext)
1960 Producer.appendChild(CompanyName)
1961
1962 TaxIdentificationNumber = doc2.createElement("TaxIdentificationNumber")
1963 ptext = doc1.createTextNode(nafta_cer_orig["Contacts"]['Producer']['TaxIdentificationNumber'])
1964 TaxIdentificationNumber.appendChild(ptext)
1965 Producer.appendChild(TaxIdentificationNumber)
1966
1967 Address = doc2.createElement("Address")
1968 Producer.appendChild(Address)
1969
1970 AddressLine1 = doc2.createElement("AddressLine1")
1971 ptext = doc1.createTextNode(nafta_cer_orig["Contacts"]['Producer']['Address']['AddressLine1'])
1972 AddressLine1.appendChild(ptext)
1973 Address.appendChild(AddressLine1)
1974
1975 AddressLine2 = doc2.createElement("AddressLine2")
1976 ptext = doc1.createTextNode(nafta_cer_orig["Contacts"]['Producer']['Address']['AddressLine2'])
1977 AddressLine2.appendChild(ptext)
1978 Address.appendChild(AddressLine2)
1979
1980 City = doc2.createElement("City")
1981 ptext = doc1.createTextNode(nafta_cer_orig["Contacts"]['Producer']['Address']['City'])
1982 City.appendChild(ptext)
1983 Address.appendChild(City)
1984
1985 StateProvinceCode = doc2.createElement("StateProvinceCode")
1986 ptext = doc1.createTextNode(nafta_cer_orig["Contacts"]['Producer']['Address']['StateProvinceCode'])
1987 StateProvinceCode.appendChild(ptext)
1988 Address.appendChild(StateProvinceCode)
1989
1990 PostalCode = doc2.createElement("PostalCode")
1991 ptext = doc1.createTextNode(nafta_cer_orig["Contacts"]['Producer']['Address']['PostalCode'])
1992 PostalCode.appendChild(ptext)
1993 Address.appendChild(PostalCode)
1994
1995 CountryCode = doc2.createElement("CountryCode")
1996 ptext = doc1.createTextNode(nafta_cer_orig["Contacts"]['Producer']['Address']['CountryCode'])
1997 CountryCode.appendChild(ptext)
1998 Address.appendChild(CountryCode)
1999
2000 Product_count = len(prod) > 50 and 50 or len(prod)
2001 if comm_inv or cer_orig or nafta_cer_orig or sed:
2002 for i in range (0,Product_count):
2003 #///////////
2004 #########code for product dictionary
2005 #///////////
2006
2007 Product = doc2.createElement("Product")
2008 InternationalForms.appendChild(Product)
2009
2010 Description = doc2.createElement("Description")
2011 ptext = doc1.createTextNode(prod[i]['Description'])
2012 Description.appendChild(ptext)
2013 Product.appendChild(Description)
2014 if comm_inv:
2015 Unit = doc2.createElement("Unit")
2016 Product.appendChild(Unit)
2017 Number = doc2.createElement("Number")
2018 ptext = doc1.createTextNode(prod[i]['Unit']['Number'])
2019 Number.appendChild(ptext)
2020 Unit.appendChild(Number)
2021
2022 Value = doc2.createElement("Value")
2023 ptext = doc1.createTextNode(prod[i]['Unit']['Value'])
2024 Value.appendChild(ptext)
2025 Unit.appendChild(Value)
2026
2027 UnitOfMeasurement = doc2.createElement("UnitOfMeasurement")
2028 Unit.appendChild(UnitOfMeasurement)
2029 Code = doc2.createElement("Code")
2030 ptext = doc1.createTextNode(prod[i]['Unit']['UnitOfMeasurement']['Code'])
2031 Code.appendChild(ptext)
2032 UnitOfMeasurement.appendChild(Code)
2033
2034 Description = doc2.createElement("Description")
2035 ptext = doc1.createTextNode(prod[i]['Unit']['UnitOfMeasurement']['Description'])
2036 Description.appendChild(ptext)
2037 UnitOfMeasurement.appendChild(Description)
2038 if nafta_cer_orig or comm_inv:
2039 CommodityCode = doc2.createElement("CommodityCode")
2040 ptext = doc1.createTextNode(prod[i]['CommodityCode'])
2041 CommodityCode.appendChild(ptext)
2042 Product.appendChild(CommodityCode)
2043# if comm_inv:
2044# PartNumber = doc2.createElement("PartNumber")
2045# ptext = doc1.createTextNode(prod[i]['PartNumber'])
2046# CommodityCode.appendChild(ptext)
2047# Product.appendChild(PartNumber)
2048 if nafta_cer_orig or comm_inv or cer_orig:
2049 OriginCountryCode = doc2.createElement("OriginCountryCode")
2050 ptext = doc1.createTextNode(prod[i]['OriginCountryCode'])
2051 OriginCountryCode.appendChild(ptext)
2052 Product.appendChild(OriginCountryCode)
2053 if nafta_cer_orig:
2054# JointProductionIndicator = doc2.createElement("JointProductionIndicator")
2055# ptext = doc1.createTextNode(prod[i]['JointProductionIndicator'])
2056# JointProductionIndicator.appendChild(ptext)
2057# Product.appendChild(JointProductionIndicator)
2058
2059 NetCostCode = doc2.createElement("NetCostCode")
2060 ptext = doc1.createTextNode(prod[i]['NetCostCode'])
2061 NetCostCode.appendChild(ptext)
2062 Product.appendChild(NetCostCode)
2063
2064# NetCostDateRange = doc2.createElement("NetCostDateRange")
2065# Product.appendChild(NetCostDateRange)
2066# BeginDate = doc2.createElement("BeginDate")
2067# ptext = doc1.createTextNode(prod[i]['NetCostDateRange']['BeginDate'])
2068# BeginDate.appendChild(ptext)
2069# NetCostDateRange.appendChild(BeginDate)
2070#
2071# EndDate = doc2.createElement("EndDate")
2072# ptext = doc1.createTextNode(prod[i]['NetCostDateRange']['EndDate'])
2073# EndDate.appendChild(ptext)
2074# NetCostDateRange.appendChild(EndDate)
2075
2076 PreferenceCriteria = doc2.createElement("PreferenceCriteria")
2077 ptext = doc1.createTextNode(prod[i]['PreferenceCriteria'])
2078 PreferenceCriteria.appendChild(ptext)
2079 Product.appendChild(PreferenceCriteria)
2080
2081
2082 ProducerInfo = doc2.createElement("ProducerInfo")
2083 ptext = doc1.createTextNode(prod[i]['ProducerInfo'])
2084 ProducerInfo.appendChild(ptext)
2085 Product.appendChild(ProducerInfo)
2086 if cer_orig:
2087# MarksAndNumbers = doc2.createElement("MarksAndNumbers")
2088# ptext = doc1.createTextNode(prod[i]['MarksAndNumbers'])
2089# MarksAndNumbers.appendChild(ptext)
2090# Product.appendChild(MarksAndNumbers)
2091
2092 NumberOfPackagesPerCommodity = doc2.createElement("NumberOfPackagesPerCommodity")
2093 ptext = doc1.createTextNode(prod[i]['NumberOfPackagesPerCommodity'])
2094 NumberOfPackagesPerCommodity.appendChild(ptext)
2095 Product.appendChild(NumberOfPackagesPerCommodity)
2096
2097
2098 ProductWeight = doc2.createElement("ProductWeight")
2099 Product.appendChild(ProductWeight)
2100 UnitOfMeasurement = doc2.createElement("UnitOfMeasurement")
2101 ProductWeight.appendChild(UnitOfMeasurement)
2102 Code = doc2.createElement("Code")
2103 ptext = doc1.createTextNode(prod[i]['ProductWeight']['UnitOfMeasurement']['Code'])
2104 Code.appendChild(ptext)
2105 UnitOfMeasurement.appendChild(Code)
2106
2107 Description = doc2.createElement("Description")
2108 ptext = doc1.createTextNode(prod[i]['ProductWeight']['UnitOfMeasurement']['Description'])
2109 Description.appendChild(ptext)
2110 UnitOfMeasurement.appendChild(Description)
2111
2112 Weight = doc2.createElement("Weight")
2113 ptext = doc1.createTextNode(prod[i]['ProductWeight']['Weight'])
2114 Weight.appendChild(ptext)
2115 ProductWeight.appendChild(Weight)
2116# if sed:
2117# VehicleID = doc2.createElement("VehicleID")
2118# ptext = doc1.createTextNode(prod[i]['VehicleID'])
2119# VehicleID.appendChild(ptext)
2120# Product.appendChild(VehicleID)
2121#
2122# ScheduleB = doc2.createElement("ScheduleB")
2123# Product.appendChild(ScheduleB)
2124# Number = doc2.createElement("Number")
2125# ptext = doc1.createTextNode(prod[i]['ScheduleB']['Number'])
2126# Number.appendChild(ptext)
2127# ScheduleB.appendChild(Number)
2128#
2129# Quantity = doc2.createElement("Quantity")
2130# ptext = doc1.createTextNode(prod[i]['ScheduleB']['Quantity'])
2131# Quantity.appendChild(ptext)
2132# ScheduleB.appendChild(Quantity)
2133#
2134# UnitOfMeasurement = doc2.createElement("UnitOfMeasurement")
2135# ScheduleB.appendChild(UnitOfMeasurement)
2136# Code = doc2.createElement("Code")
2137# ptext = doc1.createTextNode(prod[i]['ScheduleB']['UnitOfMeasurement']['Code'])
2138# Code.appendChild(ptext)
2139# UnitOfMeasurement.appendChild(Code)
2140#
2141# Description = doc2.createElement("Description")
2142# ptext = doc1.createTextNode(prod[i]['ScheduleB']['UnitOfMeasurement']['Description'])
2143# Description.appendChild(ptext)
2144# UnitOfMeasurement.appendChild(Description)
2145#
2146# ExportType = doc2.createElement("ExportType")
2147# ptext = doc1.createTextNode(prod[i]['ExportType'])
2148# Description.appendChild(ptext)
2149# Product.appendChild(ExportType)
2150#
2151# SEDTotalValue = doc2.createElement("SEDTotalValue")
2152# ptext = doc1.createTextNode(prod[i]['SEDTotalValue'])
2153# SEDTotalValue.appendChild(ptext)
2154# Product.appendChild(SEDTotalValue)
2155#
2156
2157 #/////////end loop in code
2158
2159
2160 if comm_inv:
2161# InvoiceNumber = doc2.createElement("InvoiceNumber")
2162# ptext = doc1.createTextNode(comm_inv["InvoiceNumber"])
2163# InvoiceNumber.appendChild(ptext)
2164# InternationalForms.appendChild(InvoiceNumber)
2165 if comm_inv.get("InvoiceDate"):
2166 InvoiceDate = doc2.createElement("InvoiceDate")
2167 ptext = doc1.createTextNode(comm_inv["InvoiceDate"])
2168 InvoiceDate.appendChild(ptext)
2169 InternationalForms.appendChild(InvoiceDate)
2170
2171# PurchaseOrderNumber = doc2.createElement("PurchaseOrderNumber")
2172# ptext = doc1.createTextNode(comm_inv["PurchaseOrderNumber"])
2173# InvoiceNumber.appendChild(ptext)
2174# InternationalForms.appendChild(PurchaseOrderNumber)
2175#
2176# TermsOfShipment = doc2.createElement("TermsOfShipment")
2177# ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["ShipmentServiceOptions"]["InternationalForms"]["TermsOfShipment"])
2178# TermsOfShipment.appendChild(ptext)
2179# InternationalForms.appendChild(TermsOfShipment)
2180
2181 ReasonForExport = doc2.createElement("ReasonForExport")
2182 ptext = doc1.createTextNode(comm_inv["ReasonForExport"])
2183 ReasonForExport.appendChild(ptext)
2184 InternationalForms.appendChild(ReasonForExport)
2185
2186# Comments = doc2.createElement("Comments")
2187# ptext = doc1.createTextNode(comm_inv["Comments"])
2188# Comments.appendChild(ptext)
2189# InternationalForms.appendChild(Comments)
2190
2191 DeclarationStatement = doc2.createElement("DeclarationStatement")
2192 ptext = doc1.createTextNode(comm_inv["DeclarationStatement"])
2193 DeclarationStatement.appendChild(ptext)
2194 InternationalForms.appendChild(DeclarationStatement)
2195
2196# Discount = doc2.createElement("Discount")
2197# InternationalForms.appendChild(Discount)
2198#
2199# MonetaryValue = doc2.createElement("MonetaryValue")
2200# ptext = doc1.createTextNode(comm_inv['Discount']["MonetaryValue"])
2201# MonetaryValue.appendChild(ptext)
2202# Discount.appendChild(MonetaryValue)
2203#
2204# FreightCharges = doc2.createElement("FreightCharges")
2205# InternationalForms.appendChild(FreightCharges)
2206# MonetaryValue = doc2.createElement("MonetaryValue")
2207# ptext = doc1.createTextNode(comm_inv['FreightCharges']["MonetaryValue"])
2208# MonetaryValue.appendChild(ptext)
2209# FreightCharges.appendChild(MonetaryValue)
2210#
2211# InsuranceCharges = doc2.createElement("InsuranceCharges")
2212# InternationalForms.appendChild(InsuranceCharges)
2213# MonetaryValue = doc2.createElement("MonetaryValue")
2214# ptext = doc1.createTextNode(comm_inv['InsuranceCharges']["MonetaryValue"])
2215# MonetaryValue.appendChild(ptext)
2216# InsuranceCharges.appendChild(MonetaryValue)
2217#
2218# OtherCharges = doc2.createElement("OtherCharges")
2219# InternationalForms.appendChild(OtherCharges)
2220# MonetaryValue = doc2.createElement("MonetaryValue")
2221# ptext = doc1.createTextNode(comm_inv['OtherCharges']["MonetaryValue"])
2222# MonetaryValue.appendChild(ptext)
2223# OtherCharges.appendChild(MonetaryValue)
2224#
2225# Description = doc2.createElement("Description")
2226# ptext = doc1.createTextNode(comm_inv['OtherCharges']["Description"])
2227# Description.appendChild(ptext)
2228# OtherCharges.appendChild(Description)
2229
2230 CurrencyCode = doc2.createElement("CurrencyCode")
2231 ptext = doc1.createTextNode(comm_inv["CurrencyCode"])
2232 CurrencyCode.appendChild(ptext)
2233 InternationalForms.appendChild(CurrencyCode)
2234 if nafta_cer_orig and nafta_cer_orig.get('BlanketPeriod'):
2235 BlanketPeriod = doc2.createElement("BlanketPeriod")
2236 InternationalForms.appendChild(BlanketPeriod)
2237
2238 BeginDate = doc2.createElement("BeginDate")
2239 ptext = doc1.createTextNode(nafta_cer_orig['BlanketPeriod']["BeginDate"])
2240 BeginDate.appendChild(ptext)
2241 BlanketPeriod.appendChild(BeginDate)
2242
2243 EndDate = doc2.createElement("EndDate")
2244 ptext = doc1.createTextNode(nafta_cer_orig['BlanketPeriod']["EndDate"])
2245 EndDate.appendChild(ptext)
2246 BlanketPeriod.appendChild(EndDate)
2247 if cer_orig or sed:
2248 ExportDate = doc2.createElement("ExportDate")
2249 ptext = doc1.createTextNode(cer_orig['ExportDate'])
2250 ExportDate.appendChild(ptext)
2251 InternationalForms.appendChild(ExportDate)
2252
2253 ExportingCarrier = doc2.createElement("ExportingCarrier")
2254 ptext = doc1.createTextNode(cer_orig['ExportingCarrier'])
2255 ExportingCarrier.appendChild(ptext)
2256 InternationalForms.appendChild(ExportingCarrier)
2257# if sed:
2258# if sed['CarrierID']:
2259# CarrierID = doc2.createElement("CarrierID")
2260# ptext = doc1.createTextNode(sed['CarrierID'])
2261# CarrierID.appendChild(ptext)
2262# InternationalForms.appendChild(CarrierID)
2263#
2264# InBondCode = doc2.createElement("InBondCode")
2265# ptext = doc1.createTextNode(sed['InBondCode'])
2266# InBondCode.appendChild(ptext)
2267# InternationalForms.appendChild(InBondCode)
2268# if sed['InBondCode'] != '70':
2269# EntryNumber = doc2.createElement("EntryNumber")
2270# ptext = doc1.createTextNode(sed['EntryNumber'])
2271# EntryNumber.appendChild(ptext)
2272# InternationalForms.appendChild(EntryNumber)
2273#
2274# PointOfOrigin = doc2.createElement("PointOfOrigin")
2275# ptext = doc1.createTextNode(sed['PointOfOrigin'])
2276# PointOfOrigin.appendChild(ptext)
2277# InternationalForms.appendChild(PointOfOrigin)
2278#
2279# ModeOfTransport = doc2.createElement("ModeOfTransport")
2280# ptext = doc1.createTextNode(sed['ModeOfTransport'])
2281# ModeOfTransport.appendChild(ptext)
2282# InternationalForms.appendChild(ModeOfTransport)
2283# if sed['PortOfExport']:
2284# PortOfExport = doc2.createElement("PortOfExport")
2285# ptext = doc1.createTextNode(sed['PortOfExport'])
2286# PortOfExport.appendChild(ptext)
2287# InternationalForms.appendChild(PortOfExport)
2288# if sed['PortOfUnloading']:
2289# PortOfUnloading = doc2.createElement("PortOfUnloading")
2290# ptext = doc1.createTextNode(sed['PortOfUnloading'])
2291# PortOfUnloading.appendChild(ptext)
2292# InternationalForms.appendChild(PortOfUnloading)
2293# if sed['LoadingPier']:
2294# LoadingPier = doc2.createElement("LoadingPier")
2295# ptext = doc1.createTextNode(sed['LoadingPier'])
2296# LoadingPier.appendChild(ptext)
2297# InternationalForms.appendChild(LoadingPier)
2298# if sed['PartiesToTransaction']:
2299# PartiesToTransaction = doc2.createElement("PartiesToTransaction")
2300# ptext = doc1.createTextNode(sed['PartiesToTransaction'])
2301# PartiesToTransaction.appendChild(ptext)
2302# InternationalForms.appendChild(PartiesToTransaction)
2303#
2304# if sed['RoutedExportTransactionIndicator']:
2305# RoutedExportTransactionIndicator = doc2.createElement("RoutedExportTransactionIndicator")
2306# InternationalForms.appendChild(RoutedExportTransactionIndicator)
2307#
2308# if sed['ContainerizedIndicator']:
2309# ContainerizedIndicator = doc2.createElement("ContainerizedIndicator")
2310# InternationalForms.appendChild(ContainerizedIndicator)
2311#
2312# License = doc2.createElement("License")
2313# InternationalForms.appendChild(License)
2314# if sed['License'].get('Number'):
2315# Number = doc2.createElement("Number")
2316# ptext = doc1.createTextNode(sed['License']['Number'])
2317# Number.appendChild(ptext)
2318# License.appendChild(Number)
2319#
2320# Date = doc2.createElement("Date")
2321# ptext = doc1.createTextNode(sed['License']['Date'])
2322# Date.appendChild(ptext)
2323# InternationalForms.appendChild(Date)
2324#
2325# elif sed['License'].get('ExceptionCode'):
2326# ExceptionCode = doc2.createElement("ExceptionCode")
2327# ptext = doc1.createTextNode(sed['License']['ExceptionCode'])
2328# ExceptionCode.appendChild(ptext)
2329# License.appendChild(ExceptionCode)
2330# if sed['License']['ExceptionCode'] in ('CIV','CTP','ENC','KMI','LVS'):
2331# ECCNNumber = doc2.createElement("ECCNNumber")
2332# ptext = doc1.createTextNode(sed['ECCNNumber'])
2333# ECCNNumber.appendChild(ptext)
2334# InternationalForms.appendChild(ECCNNumber)
2335
2336 # ReturnOfDocumentIndicator = doc2.createElement("ReturnOfDocumentIndicator")
2337 # ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["ShipmentServiceOptions"]["ReturnOfDocumentIndicator"])
2338 # ReturnOfDocumentIndicator.appendChild(ptext)
2339 # ShipmentServiceOptions.appendChild(ReturnOfDocumentIndicator)
2340 #
2341 # ImportControlIndicator = doc2.createElement("ImportControlIndicator")
2342 # ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["ShipmentServiceOptions"]["ImportControlIndicator"])
2343 # ImportControlIndicator.appendChild(ptext)
2344 # ShipmentServiceOptions.appendChild(ImportControlIndicator)
2345 #
2346 # LabelMethod = doc2.createElement("LabelMethod")
2347 # ShipmentServiceOptions.appendChild(LabelMethod)
2348 # Code = doc2.createElement("Code")
2349 # ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["ShipmentServiceOptions"]["LabelMethod"]["Code"])
2350 # Code.appendChild(ptext)
2351 # LabelMethod.appendChild(Code)
2352 #
2353 # Description = doc2.createElement("Description")
2354 # ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["ShipmentServiceOptions"]["LabelMethod"]["Description"])
2355 # Description.appendChild(ptext)
2356 # LabelMethod.appendChild(Description)
2357
2358 # CommercialInvoiceRemovalIndicator = doc2.createElement("CommercialInvoiceRemovalIndicator")
2359 # ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["ShipmentServiceOptions"]["CommercialInvoiceRemovalIndicator"])
2360 # CommercialInvoiceRemovalIndicator.appendChild(ptext)
2361 # ShipmentServiceOptions.appendChild(CommercialInvoiceRemovalIndicator)
2362
2363 # UPScarbonneutralIndicator = doc2.createElement("UPScarbonneutralIndicator")
2364 # ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["ShipmentServiceOptions"]["UPScarbonneutralIndicator"])
2365 # UPScarbonneutralIndicator.appendChild(ptext)
2366 # ShipmentServiceOptions.appendChild(UPScarbonneutralIndicator)
2367
2368 # DeliveryConfirmation = doc2.createElement("DeliveryConfirmation")
2369 # ShipmentServiceOptions.appendChild(DeliveryConfirmation)
2370 # DCISType = doc2.createElement("DCISType")
2371 # ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["ShipmentServiceOptions"]["DeliveryConfirmation"]["DCISType"])
2372 # DCISType.appendChild(ptext)
2373 # DeliveryConfirmation.appendChild(DCISType)
2374
2375 Package_count = len(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["Package"])
2376 for i in range(0,Package_count):
2377 Package = doc2.createElement("Package")
2378 Shipment.appendChild(Package)
2379
2380 Description = doc2.createElement("Description")
2381 ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["Package"][i]["Description"])
2382 Description.appendChild(ptext)
2383 Package.appendChild(Description)
2384 PackagingType = doc2.createElement("PackagingType")
2385 Package.appendChild(PackagingType)
2386
2387 Code = doc2.createElement("Code")
2388 ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["Package"][i]["PackagingType"]['Code'])
2389 Code.appendChild(ptext)
2390 PackagingType.appendChild(Code)
2391 Description = doc2.createElement("Description")
2392 ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["Package"][i]["PackagingType"]['Description'])
2393 Description.appendChild(ptext)
2394 PackagingType.appendChild(Description)
2395
2396 Dimensions = doc2.createElement("Dimensions")
2397 Package.appendChild(Dimensions)
2398
2399 Length = doc2.createElement("Length")
2400 ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["Package"][i]["Dimensions"]["Length"])
2401 Length.appendChild(ptext)
2402 Dimensions.appendChild(Length)
2403 Width = doc2.createElement("Width")
2404 ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["Package"][i]["Dimensions"]["Width"])
2405 Width.appendChild(ptext)
2406 Dimensions.appendChild(Width)
2407 Height = doc2.createElement("Height")
2408 ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["Package"][i]["Dimensions"]["Height"])
2409 Height.appendChild(ptext)
2410 Dimensions.appendChild(Height)
2411 UnitOfMeasurement = doc2.createElement("UnitOfMeasurement")
2412 Dimensions.appendChild(UnitOfMeasurement)
2413
2414 Code = doc2.createElement("Code")
2415 ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["Package"][i]["Dimensions"]['UnitOfMeasurement']["Code"])
2416 Code.appendChild(ptext)
2417 UnitOfMeasurement.appendChild(Code)
2418 Description = doc2.createElement("Description")
2419 ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["Package"][i]["Dimensions"]['UnitOfMeasurement']["Description"])
2420 Description.appendChild(ptext)
2421 UnitOfMeasurement.appendChild(Description)
2422
2423
2424 PackageWeight = doc2.createElement("PackageWeight")
2425 Package.appendChild(PackageWeight)
2426
2427 UnitOfMeasurement = doc2.createElement("UnitOfMeasurement")
2428 PackageWeight.appendChild(UnitOfMeasurement)
2429 Code = doc2.createElement("Code")
2430 ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["Package"][i]['PackageWeight']['UnitOfMeasurement']["Code"])
2431 Code.appendChild(ptext)
2432 UnitOfMeasurement.appendChild(Code)
2433
2434 Description = doc2.createElement("Description")
2435 ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["Package"][i]['PackageWeight']['UnitOfMeasurement']["Description"])
2436 Description.appendChild(ptext)
2437 UnitOfMeasurement.appendChild(Description)
2438
2439 Weight = doc2.createElement("Weight")
2440 ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["Package"][i]['PackageWeight']["Weight"])
2441 Weight.appendChild(ptext)
2442 PackageWeight.appendChild(Weight)
2443 # LargePackageIndicator = doc2.createElement("LargePackageIndicator")
2444 ## ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["Package"][i]["LargePackageIndicator"])
2445 ## LargePackageIndicator.appendChild(ptext)
2446 # Package.appendChild(LargePackageIndicator)
2447
2448# ReferenceNumber = doc2.createElement("ReferenceNumber")
2449# Package.appendChild(ReferenceNumber)
2450#
2451# BarCodeIndicator = doc2.createElement("BarCodeIndicator")
2452# # ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["Package"][i]["ReferenceNumber"]["BarCodeIndicator"])
2453# # BarCodeIndicator.appendChild(ptext)
2454# ReferenceNumber.appendChild(BarCodeIndicator)
2455#
2456# Code = doc2.createElement("Code")
2457# ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["Package"][i]["ReferenceNumber"]["Code"])
2458# Code.appendChild(ptext)
2459# ReferenceNumber.appendChild(Code)
2460#
2461# Value = doc2.createElement("Value")
2462# ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["Package"][i]["ReferenceNumber"]["Value"])
2463# Value.appendChild(ptext)
2464# ReferenceNumber.appendChild(Value)
2465
2466 # AdditionalHandling = doc2.createElement("AdditionalHandling")
2467 # ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["Package"][i]["AdditionalHandling"])
2468 # AdditionalHandling.appendChild(ptext)
2469 # Package.appendChild(AdditionalHandling)
2470
2471 # PackageServiceOptions = doc2.createElement("PackageServiceOptions")
2472 # Package.appendChild(PackageServiceOptions)
2473 #
2474 # DeliveryConfirmation = doc2.createElement("DeliveryConfirmation")
2475 # PackageServiceOptions.appendChild(DeliveryConfirmation)
2476 #
2477 # DCISType = doc2.createElement("DCISType")
2478 # ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["Package"][i]["PackageServiceOptions"]['DeliveryConfirmation']['DCISType'])
2479 # DCISType.appendChild(ptext)
2480 # DeliveryConfirmation.appendChild(DCISType)
2481 #
2482 # DCISNumber = doc2.createElement("DCISNumber")
2483 # ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["Package"][i]["PackageServiceOptions"]['DeliveryConfirmation']['DCISNumber'])
2484 # DCISNumber.appendChild(ptext)
2485 # DeliveryConfirmation.appendChild(DCISNumber)
2486 #
2487 # InsuredValue = doc2.createElement("InsuredValue")
2488 # PackageServiceOptions.appendChild(InsuredValue)
2489 #
2490 #
2491 # Type = doc2.createElement("Type")
2492 # ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["Package"][i]["PackageServiceOptions"]['InsuredValue']['Type'])
2493 # Type.appendChild(ptext)
2494 # InsuredValue.appendChild(Type)
2495 #
2496 # Code = doc2.createElement("Code")
2497 # ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["Package"][i]["PackageServiceOptions"]['InsuredValue']['Code'])
2498 # Code.appendChild(ptext)
2499 # InsuredValue.appendChild(Code)
2500 #
2501 #
2502 # Description = doc2.createElement("Description")
2503 # ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["Package"][i]["PackageServiceOptions"]['InsuredValue']['Description'])
2504 # Description.appendChild(ptext)
2505 # InsuredValue.appendChild(Description)
2506 #
2507 # Description = doc2.createElement("CurrencyCode")
2508 # ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["Package"][i]["PackageServiceOptions"]['InsuredValue']['CurrencyCode'])
2509 # CurrencyCode.appendChild(ptext)
2510 # InsuredValue.appendChild(CurrencyCode)
2511 #
2512 # Description = doc2.createElement("MonetaryValue")
2513 # ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["Package"][i]["PackageServiceOptions"]['InsuredValue']['MonetaryValue'])
2514 # MonetaryValue.appendChild(ptext)
2515 # InsuredValue.appendChild(MonetaryValue)
2516 #
2517 #
2518 # COD = doc2.createElement("COD")
2519 # PackageServiceOptions.appendChild(COD)
2520 #
2521 #
2522 # CODCode = doc2.createElement("CODCode")
2523 # ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["Package"][i]["PackageServiceOptions"]['COD']['CODCode'])
2524 # CODCode.appendChild(ptext)
2525 # COD.appendChild(CODCode)
2526 #
2527 # CODFundsCode = doc2.createElement("CODFundsCode")
2528 # ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["Package"][i]["PackageServiceOptions"]['COD']['CODFundsCode'])
2529 # CODFundsCode.appendChild(ptext)
2530 # COD.appendChild(CODFundsCode)
2531 #
2532 # CODAmount = doc2.createElement("CODAmount")
2533 # ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["Package"][i]["PackageServiceOptions"]['COD']['CODAmount'])
2534 # CODAmount.appendChild(ptext)
2535 # COD.appendChild(CODAmount)
2536 #
2537 # CurrencyCode = doc2.createElement("CurrencyCode")
2538 # ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["Package"][i]["PackageServiceOptions"]['InsuredValue']['COD']['CODAmount']['CurrencyCode'])
2539 # CurrencyCode.appendChild(ptext)
2540 # InsuredValue.appendChild(CurrencyCode)
2541 #
2542 # MonetaryValue = doc2.createElement("MonetaryValue")
2543 # ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["Package"][i]["PackageServiceOptions"]['InsuredValue']['COD']['CODAmount']['MonetaryValue'])
2544 # MonetaryValue.appendChild(ptext)
2545 # InsuredValue.appendChild(MonetaryValue)
2546 #
2547 # VerbalConfirmation = doc2.createElement("VerbalConfirmation")
2548 # PackageServiceOptions.appendChild(VerbalConfirmation)
2549 #
2550 # ContactInfo = doc2.createElement("ContactInfo")
2551 # VerbalConfirmation.appendChild(ContactInfo)
2552 #
2553 # Name = doc2.createElement("Name")
2554 # ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["Package"][i]["PackageServiceOptions"]['VerbalConfirmation']['VerbalConfirmation']['Name'])
2555 # Name.appendChild(ptext)
2556 # ContactInfo.appendChild(Name)
2557 #
2558 # PhoneNumber = doc2.createElement("PhoneNumber")
2559 # ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["Package"][i]["PackageServiceOptions"]['VerbalConfirmation']['VerbalConfirmation']['PhoneNumber'])
2560 # PhoneNumber.appendChild(ptext)
2561 # ContactInfo.appendChild(PhoneNumber)
2562 #
2563 # ShipperReleaseIndicator = doc2.createElement("ShipperReleaseIndicator")
2564 # ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["Package"][i]["PackageServiceOptions"]['ShipperReleaseIndicator'])
2565 # ShipperReleaseIndicator.appendChild(ptext)
2566 # PackageServiceOptions.appendChild(ShipperReleaseIndicator)
2567 #
2568 #
2569 # Notification = doc2.createElement("Notification")
2570 # PackageServiceOptions.appendChild(Notification)
2571 # NotificationCode = doc2.createElement("NotificationCode")
2572 # ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["Package"][i]["PackageServiceOptions"]['Notification'])
2573 # NotificationCode.appendChild(ptext)
2574 # Notification.appendChild(NotificationCode)
2575 #
2576 # EMailMessage = doc2.createElement("EMailMessage")
2577 # Notification.appendChild(EMailMessage)
2578 # UndeliverableEMailAddress = doc2.createElement("UndeliverableEMailAddress")
2579 # ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["Package"][i]["PackageServiceOptions"]["Notification"]["EMailMessage"]["UndeliverableEMailAddress"])
2580 # UndeliverableEMailAddress.appendChild(ptext)
2581 # EMailMessage.appendChild(UndeliverableEMailAddress)
2582 #
2583 # EMailAddress = doc2.createElement("EMailAddress")
2584 # ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["Package"][i]["PackageServiceOptions"]["Notification"]["EMailMessage"]["EMailAddress"])
2585 # EMailAddress.appendChild(ptext)
2586 # EMailMessage.appendChild(EMailAddress)
2587 #
2588 # FromEMailAddress = doc2.createElement("FromEMailAddress")
2589 # ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["Package"][i]["PackageServiceOptions"]["Notification"]["EMailMessage"]["FromEMailAddress"])
2590 # FromEMailAddress.appendChild(ptext)
2591 # EMailMessage.appendChild(FromEMailAddress)
2592 #
2593 # FromName = doc2.createElement("FromName")
2594 # ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["Package"][i]["PackageServiceOptions"]["Notification"]["EMailMessage"]["FromName"])
2595 # FromName.appendChild(ptext)
2596 # EMailMessage.appendChild(FromName)
2597 #
2598 # Memo = doc2.createElement("Memo")
2599 # ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["Package"][i]["PackageServiceOptions"]["Notification"]["EMailMessage"]["Memo"])
2600 # Memo.appendChild(ptext)
2601 # EMailMessage.appendChild(Memo)
2602 #
2603 # Subject = doc2.createElement("Subject")
2604 # ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["Package"][i]["PackageServiceOptions"]["Notification"]["EMailMessage"]["Subject"])
2605 # Subject.appendChild(ptext)
2606 # EMailMessage.appendChild(Subject)
2607 #
2608 # SubjectCode = doc2.createElement("SubjectCode")
2609 # ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["Package"][i]["PackageServiceOptions"]["Notification"]["EMailMessage"]["SubjectCode"])
2610 # SubjectCode.appendChild(ptext)
2611 # EMailMessage.appendChild(SubjectCode)
2612 #
2613 # ReturnsFlexibleAccessIndicator = doc2.createElement("ReturnsFlexibleAccessIndicator")
2614 # ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["Shipment"]["Package"][i]["PackageServiceOptions"]['ReturnsFlexibleAccessIndicator'])
2615 # ReturnsFlexibleAccessIndicator.appendChild(ptext)
2616 # PackageServiceOptions.appendChild(ReturnsFlexibleAccessIndicator)
2617
2618
2619
2620
2621
2622
2623 #/////////end loop in code
2624
2625
2626
2627 LabelSpecification = doc2.createElement("LabelSpecification")
2628 ShipmentConfirmRequest.appendChild(LabelSpecification)
2629
2630 LabelPrintMethod = doc2.createElement("LabelPrintMethod")
2631 LabelSpecification.appendChild(LabelPrintMethod)
2632 Code = doc2.createElement("Code")
2633 ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["LabelSpecification"]["LabelPrintMethod"]["Code"])
2634 Code.appendChild(ptext)
2635 LabelPrintMethod.appendChild(Code)
2636
2637 Description = doc2.createElement("Description")
2638 ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["LabelSpecification"]["LabelPrintMethod"]["Description"])
2639 Description.appendChild(ptext)
2640 LabelPrintMethod.appendChild(Description)
2641
2642 # HTTPUserAgent = doc2.createElement("HTTPUserAgent")
2643 # ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["LabelSpecification"]["LabelPrintMethod"]["HTTPUserAgent"])
2644 # HTTPUserAgent.appendChild(ptext)
2645 # LabelSpecification.appendChild(HTTPUserAgent)
2646
2647 LabelStockSize = doc2.createElement("LabelStockSize")
2648 LabelSpecification.appendChild(LabelStockSize)
2649 Height = doc2.createElement("Height")
2650 ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["LabelSpecification"]["LabelStockSize"]["Height"])
2651 Height.appendChild(ptext)
2652 LabelStockSize.appendChild(Height)
2653 Width = doc2.createElement("Width")
2654 ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["LabelSpecification"]["LabelStockSize"]["Width"])
2655 Width.appendChild(ptext)
2656 LabelStockSize.appendChild(Width)
2657
2658 LabelImageFormat = doc2.createElement("LabelImageFormat")
2659 LabelSpecification.appendChild(LabelImageFormat)
2660
2661 Code = doc2.createElement("Code")
2662 ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["LabelSpecification"]["LabelImageFormat"]["Code"])
2663 Code.appendChild(ptext)
2664 LabelImageFormat.appendChild(Code)
2665
2666 Description = doc2.createElement("Description")
2667 ptext = doc1.createTextNode(data_for_confirm_request["ShipmentConfirmRequest"]["LabelSpecification"]["LabelImageFormat"]["Description"])
2668 Description.appendChild(ptext)
2669 LabelImageFormat.appendChild(Description)
2670
2671
2672 request_string2=doc2.toprettyxml()
2673
2674 request_string=Request_string1+request_string2
2675
2676 return request_string
2677
2678 def _get_value(self,obj,template_obj,var):
2679 try :
2680 ret=''
2681 temp1='template_obj.'+var
2682 temp1=temp1.strip(' ')
2683 temp1=eval(temp1)
2684 if temp1 and '${' in temp1:
2685 temp=temp1
2686 temp=''.join(temp.split('\n'))
2687 temp_list=re.findall('\$\{.*?\}',temp)
2688 for item in temp_list:
2689 ret+=temp[0:temp.index(item)]
2690 item=item.strip('')
2691 list_item=item.strip('${')
2692 list_item=list_item.strip('}')
2693 list_item=list_item.split('object.')
2694 ret+=eval('obj.'+list_item[-1]) or ''
2695 temp=temp[temp.index(item)+len(item):]
2696 ret+=temp
2697 return ret
2698 else:
2699 return temp1
2700 except:
2701 try:
2702 return eval('template_obj.'+var)
2703 except:
2704 return ''
2705 def send_conf_mail(self,cr,uid,ids,context=None):
2706 val={}
2707 for id in ids:
2708 obj=self.browse(cr, uid, id)
2709 if obj and obj.address_id and obj.address_id.email:
2710 template_id=self.pool.get('email.template').search(cr,uid,[('object_name.model','=','stock.picking'),('ship_mail','=',True)] )
2711 if template_id:
2712 template_obj_list=self.pool.get('email.template').browse(cr,uid,template_id)
2713 for template_obj in template_obj_list:
2714 vals={'email_to':self._get_value(obj,template_obj,'def_to') or '',
2715 'body_text':self._get_value(obj,template_obj,'def_body_text') or '',
2716 'body_html':self._get_value(obj,template_obj,'def_body_html') or '',
2717 'account_id':template_obj.from_account.id,
2718 'folder':'outbox',
2719 'state':'draft',
2720 'subject':self._get_value(obj,template_obj,'def_subject') or '',
2721 'email_cc':self._get_value(obj,template_obj,'def_cc') or '',
2722 'email_bcc':self._get_value(obj,template_obj,'def_bcc') or '',
2723 'email_from':template_obj.from_account.email_id or '',
2724 'reply_to':self._get_value(obj,template_obj,'reply_to') or '' ,
2725 'date_mail':time.strftime('%Y-%m-%d %H:%M:%S'),
2726 }
2727 account = self.pool.get('email_template.mailbox').create(cr, uid,vals)
2728 return True
2729
2730 def process_ship(self,cr, uid, ids, context=None):
2731 deliv_order = self.browse(cr, uid, type(ids)==type([]) and ids[0] or ids, context=context)
2732 error_flag=False
2733 ship_move_ids={}
2734 do_transaction = True
2735 response_dic = {}
2736 if not (deliv_order.logis_company or deliv_order.shipper or deliv_order.ups_service):
2737 raise osv.except_osv("Warning", "Please select Logistics Company, Shipper and Shipping Service")
2738 if not deliv_order.packages_ids:
2739 raise osv.except_osv("Warning", "Please add shipping packages before doing Process Shipping.")
2740 if not deliv_order.invoiced and deliv_order.sale_id and deliv_order.sale_id.order_policy == 'credit_card' :
2741 if not deliv_order.sale_id.cc_pre_auth:
2742 raise osv.except_osv("Warning", "The sales order is not paid")
2743 else:
2744 do_transaction = False
2745 rel_voucher_id = deliv_order.sale_id.rel_account_voucher_id
2746 if rel_voucher_id and rel_voucher_id.state != 'posted' and deliv_order.sale_id.cc_pre_auth:
2747 self.pool.get('account.voucher').write(cr,uid,[rel_voucher_id.id],{'cc_p_authorize':False,'cc_charge':True}, context=context)
2748 do_transaction = self.pool.get('account.voucher').authorize(cr, uid, [rel_voucher_id.id], context=context)
2749 if not do_transaction:
2750 self.write(cr,uid,ids,{'ship_state':'hold','ship_message':'Unable to process creditcard payment.'})
2751 cr.commit()
2752 raise osv.except_osv(_('Final credit card charge cannot be completed!'),_("Please hold shipment and contact customer service..") )
2753 warning_error = False
2754 for pack_obj in deliv_order.packages_ids:
2755 ship_confirm_request_xml=self.create_ship_confirm_request(cr, uid,pack_obj.id)
2756 ship_confirm_web=''
2757 ship_confirm_port=''
2758
2759 if deliv_order.logis_company:
2760 if deliv_order.logis_company.test_mode:
2761 ship_confirm_web=deliv_order.logis_company.ship_req_test_web
2762 ship_confirm_port=deliv_order.logis_company.ship_req_test_port
2763
2764 else:
2765 ship_confirm_web=deliv_order.logis_company.ship_req_web
2766 ship_confirm_port=deliv_order.logis_company.ship_req_port
2767
2768 if ship_confirm_web:
2769 parse_url = urlparse(ship_confirm_web)
2770 serv = parse_url.netloc
2771 serv_path = parse_url.path
2772 else:
2773 raise osv.except_osv(_('Unable to find Shipping URL!'),_("Please configure the shipping company with websites."))
2774
2775 conn=httplib.HTTPSConnection(serv,ship_confirm_port)
2776 res=conn.request("POST",serv_path,ship_confirm_request_xml)
2777 """1.make and call function to send request/ 2.make function to process the response and write it """
2778
2779
2780 res=conn.getresponse()
2781 result = res.read()
2782
2783 response_dic=xml2dic.main(result)
2784
2785
2786 response = ''
2787
2788 if not response_dic:
2789 continue
2790 for res_elm in response_dic['ShipmentConfirmResponse'][0]['Response']:
2791 if res_elm.get('ResponseStatusCode'):
2792 response = '\nResponse Status Code: '+str(res_elm['ResponseStatusCode'])
2793 if res_elm.get('ResponseStatusDescription'):
2794 response += '\nResponse Description: '+str(res_elm['ResponseStatusDescription'])
2795 if res_elm.get('Error'):
2796
2797 error_flag =True
2798 for err_elm in res_elm.get('Error'):
2799 if err_elm.get('ErrorSeverity',False):
2800 response += '\nErrorSeverity: '+str(err_elm['ErrorSeverity'])
2801 if str(err_elm['ErrorSeverity']) == 'Warning':
2802 warning_error = True
2803 error_flag = False
2804 if err_elm.get('ErrorCode',False):
2805 response += '\nErrorCode: '+str(err_elm['ErrorCode'])
2806 if err_elm.get('ErrorDescription',False):
2807 response += '\nErrorDescription: '+str(err_elm['ErrorDescription'])
2808 if err_elm.get('ErrorLocation',False):
2809 response += '\nErrorLocation: '+str(err_elm['ErrorLocation'])
2810 self.write(cr,uid,ids,{'ship_message':'Ship Processing:'+str(response)})
2811 if not warning_error:
2812 break
2813 temp=""
2814 if len(response_dic['ShipmentConfirmResponse'])>5 and response_dic['ShipmentConfirmResponse'][5].has_key('ShipmentDigest') :
2815 temp +=str(response_dic['ShipmentConfirmResponse'][5]['ShipmentDigest'])
2816 self.pool.get('stock.packages').write(cr,uid,[pack_obj.id],{'ship_message':str(response),'shipment_digest':str(temp)})
2817
2818
2819 if int(time.strftime("%w")) in range(1,6) or (time.strftime("%w") == '6' and deliv_order.sat_delivery):
2820 next_pic_date = time.strftime("%Y-%m-%d")
2821 else:
2822 timedelta = datetime.timedelta(7-int(time.strftime("%w")))
2823 next_pic_date = (datetime.datetime.today()+timedelta).strftime("%Y-%m-%d")
2824
2825 value_dic={'pick_id':deliv_order.id ,
2826 'package_weight':pack_obj.weight,
2827 'state':deliv_order.ship_state,
2828 'partner_id':deliv_order.address_id.id and deliv_order.address_id.partner_id.id,
2829 'service':deliv_order.ups_service.id,
2830 'ship_to':deliv_order.address_id.id,
2831 'ship_from':deliv_order.ship_from and deliv_order.ship_from_address.id or deliv_order.shipper.id and deliv_order.shipper.address.id,
2832 'package':pack_obj.description and str(pack_obj.description)[:126],
2833 'pic_date':next_pic_date,
2834 'sale_id':deliv_order.sale_id.id and deliv_order.sale_id.id or False,
2835 }
2836 if not error_flag:
2837 ship_move_ids[pack_obj.id] = self.pool.get('shipping.move').create(cr, uid, value_dic)
2838 self.process_ship_accept(cr, uid, ids,ship_move_ids,pack_obj,context=context)
2839# else:
2840# error_flag =True
2841# try:
2842 if not error_flag:
2843 if warning_error:
2844 ship_msg = 'Shipping success with warning. Please see the individual package details.'
2845 else:
2846 ship_msg = 'Success'
2847 self.write(cr,uid,ids,{'ship_state':'ready_pick','ship_message':ship_msg})
2848 try:
2849 self.send_conf_mail(cr,uid,ids,context=context)
2850 except Exception,e:
2851 pass
2852 if ship_move_ids:
2853 self.pool.get('shipping.move').write(cr, uid, ship_move_ids.values(),{'state':'ready_pick'})
2854 return {
2855 'type': 'ir.actions.report.xml',
2856 'report_name':'multiple.label.print',
2857 'datas': {
2858 'model':'stock.picking',
2859 'id': ids and ids[0] or False,
2860 'ids': ids and ids or [],
2861 'report_type': 'pdf'
2862 },
2863 'nodestroy': True
2864 }
2865
2866
2867# except Exception,e:
2868# pass
2869 return True
2870
2871 def _get_journal_id(self, cr, uid, ids, context={}):
2872 journal_obj = self.pool.get('account.journal')
2873 vals = []
2874 browse_picking = self.browse(cr, uid, ids, context=context)
2875
2876 for pick in browse_picking:
2877 src_usage = pick.move_lines[0].location_id.usage
2878 dest_usage = pick.move_lines[0].location_dest_id.usage
2879 type = pick.type
2880 if type == 'out' and dest_usage == 'supplier':
2881 journal_type = 'purchase_refund'
2882 elif type == 'out' and dest_usage == 'customer':
2883 journal_type = 'sale'
2884 elif type == 'in' and src_usage == 'supplier':
2885 journal_type = 'purchase'
2886 elif type == 'in' and src_usage == 'customer':
2887 journal_type = 'sale_refund'
2888 else:
2889 journal_type = 'sale'
2890
2891 value = journal_obj.search(cr, uid, [('type', '=',journal_type )])
2892 for jr_type in journal_obj.browse(cr, uid, value, context=context):
2893 t1 = jr_type.id,jr_type.name
2894 if t1 not in vals:
2895 vals.append(t1)
2896 return vals
2897
2898
2899 def do_partial(self, cr, uid, ids, partial_datas, context=None):
2900 res = self._get_journal_id(cr, uid, ids, context=context)
2901 result_partial = super(stock_picking, self).do_partial(cr, uid, ids, partial_datas, context=context)
2902 if res and res[0]:
2903 journal_id = res[0][0]
2904 result = result_partial
2905 stock_picking_objs = self.browse(cr, uid, ids, context=context)
2906 for stock_picking_obj in stock_picking_objs:
2907 if stock_picking_obj.sale_id and stock_picking_obj.sale_id.order_policy == 'picking':
2908 pick_id = result_partial[stock_picking_obj.id]['delivered_picking']
2909 result = self.action_invoice_create(cr, uid, [pick_id], journal_id, type=None, context=context)
2910 if len(stock_picking_obj.sale_id.invoice_ids)<=1 and result:
2911 self.pool.get('account.invoice').write(cr, uid, result.values(),{'ship_method':stock_picking_obj.sale_id.ship_method,
2912 'shipcharge':stock_picking_obj.sale_id.shipcharge,
2913 'ship_method_id':stock_picking_obj.sale_id.ship_method_id and stock_picking_obj.sale_id.ship_method_id.id,})
2914
2915
2916 return result_partial
2917stock_picking()
2918
2919
2920
2921# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
02922
=== added file 'shipping_api_ups/stock_package.py'
--- shipping_api_ups/stock_package.py 1970-01-01 00:00:00 +0000
+++ shipping_api_ups/stock_package.py 2011-10-06 16:08:52 +0000
@@ -0,0 +1,92 @@
1# -*- coding: utf-8 -*-
2##############################################################################
3#
4# OpenERP, Open Source Management Solution
5# Copyright (C) 2011 NovaPoint Group LLC (<http://www.novapointgroup.com>)
6# Copyright (C) 2004-2010 OpenERP SA (<http://www.openerp.com>)
7#
8# This program is free software: you can redistribute it and/or modify
9# it under the terms of the GNU General Public License as published by
10# the Free Software Foundation, either version 3 of the License, or
11# (at your option) any later version.
12#
13# This program is distributed in the hope that it will be useful,
14# but WITHOUT ANY WARRANTY; without even the implied warranty of
15# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16# GNU General Public License for more details.
17#
18# You should have received a copy of the GNU General Public License
19# along with this program. If not, see <http://www.gnu.org/licenses/>
20#
21##############################################################################
22
23
24from osv import fields,osv
25from xml.dom.minidom import Document
26import httplib
27import xml2dic
28import base64
29
30
31class stock_packages(osv.osv):
32
33 def process_package(self,cr, uid, ids, context=None):
34 return True
35
36 _inherit = "stock.packages"
37 _columns = {
38 'shipment_digest': fields.text('ShipmentDigest'),
39 'negotiated_rates': fields.float('NegotiatedRates'),
40 'shipment_identific_no': fields.char('ShipmentIdentificationNumber', size=64, ),
41 'tracking_no': fields.char('TrackingNumber', size=64, ),
42 'logo':fields.binary('Label'),
43 'ship_message':fields.text('Status Message'),
44 'tracking_url':fields.char('Tracking URL', size=512, ),
45 }
46 _defaults = {'packge_no': False
47 }
48
49 def onchange_weight(self, cr, uid, ids, line_ids, tot_order_weight, weight,context={}):
50 '''
51 Function to automatically fill package weight
52 '''
53 ret = {}
54 if weight:
55 ret['weight'] = weight
56 else:
57 used_weight = 0
58 for line in line_ids:
59 if line and line[2] and line[2]['weight']:
60 used_weight += line[2]['weight']
61 if used_weight < tot_order_weight:
62 ret['weight'] = tot_order_weight - used_weight
63 return {'value':ret}
64 def onchange_packge_no(self, cr, uid, ids, line_ids,packge_no,context={}):
65 '''
66 Function to generate sequence on packages
67 '''
68 ret = {}
69 if packge_no:
70 ret['packge_no'] = packge_no
71 else:
72 for line in line_ids:
73 if line and line[2] and line[2]['packge_no'] and packge_no < line[2]['packge_no']:
74 packge_no=line[2]['packge_no']
75 packge_no+=1
76 ret['packge_no'] = packge_no
77 return {'value':ret}
78 def print_label(self, cr, uid, ids, context=None):
79 if not ids: return []
80 return {
81 'type': 'ir.actions.report.xml',
82 'report_name':'ship.label.print',
83 'datas': {
84 'model':'stock.packages',
85 'id': ids and ids[0] or False,
86 'ids': ids and ids or [],
87 'report_type': 'pdf'
88 },
89 'nodestroy': True
90 }
91
92stock_packages()
0\ No newline at end of file93\ No newline at end of file
194
=== added file 'shipping_api_ups/stock_package_view.xml'
--- shipping_api_ups/stock_package_view.xml 1970-01-01 00:00:00 +0000
+++ shipping_api_ups/stock_package_view.xml 2011-10-06 16:08:52 +0000
@@ -0,0 +1,107 @@
1<?xml version="1.0" encoding="UTF-8"?>
2<openerp>
3 <data>
4
5 <record id="stock_packages_tree" model="ir.ui.view">
6 <field name="name">stock.packages.tree</field>
7 <field name="model">stock.packages</field>
8 <field name="type">tree</field>
9 <field name="arch" type="xml">
10 <tree editable="bottom" string='Shipping Packages'>
11 <field name='packge_no' on_change="onchange_packge_no(parent.packages_ids,packge_no)"/>
12 <field name='weight' on_change="onchange_weight(parent.packages_ids, parent.tot_del_order_weight, weight)"/>
13 <field name='package_type'/>
14 <field name='length'/>
15 <field name='width'/>
16 <field name='height'/>
17 <field name='decl_val'/>
18 <field name='ref1'/>
19 <field name='ref2'/>
20 <field name='negotiated_rates' readonly="1"/>
21 <field name='shipment_identific_no' readonly="1"/>
22 <field name='tracking_no' readonly="1"/>
23 <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.'/>
24
25 </tree>
26 </field>
27 </record>
28
29 <!--Form view for Ups Stock Package-->
30
31 <record id="stock_packages_form" model="ir.ui.view">
32 <field name="name">stock.packages.form</field>
33 <field name="model">stock.packages</field>
34 <field name="type">form</field>
35 <field name="arch" type="xml">
36 <form string='Shipping Packages'>
37 <group colspan="4" col="4" string="">
38 <field name='packge_no' on_change="onchange_packge_no(parent.packages_ids,packge_no)"/>
39 <field name='description'/>
40 <field name='weight' on_change="onchange_weight(parent.packages_ids,parent.tot_del_order_weight, weight)"/>
41 <field name='package_type'/>
42 <field name='length'/>
43 <field name='width'/>
44 <field name='height'/>
45 <field name='decl_val'/>
46 <field name='ref1'/>
47 <field name='ref2'/><newline/>
48 <button string="Weigh" help='Click this button to weigh the package from the scale.'/>
49 <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.'/>
50 </group>
51 <newline/>
52 <group string="Shipment Status">
53 <field name='ship_message'/>
54 </group>
55 <newline/>
56 <group string="Shipping Results Details">
57 <field name='negotiated_rates' readonly="1"/>
58 <field name='shipment_identific_no' readonly="1"/>
59 <field name='tracking_no' readonly="1"/>
60 <field name='tracking_url' readonly="1" widget="url"/>
61 <field name='logo' widget="image" readonly="1"/>
62 </group>
63
64 </form>
65 </field>
66 </record>
67
68
69
70
71
72
73
74 <record id="view_picking_ups_shipping_move_inherit" model="ir.ui.view">
75 <field name="name">view_picking_ups_shipping_move_inherit</field>
76 <field name="model">shipping.move</field>
77 <field name="inherit_id" ref="shipping_api.shipping_move_form"/>
78 <field name="type">form</field>
79 <field name="arch" type="xml">
80 <xpath expr="//field[@name='ship_date']" position="after">
81 <field name='shipment_identific_no' readonly="1"/>
82 <field name='logo' widget="image" readonly="1"/>
83 <field name='tracking_url' widget="url" readonly="1"/>
84 <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.'/>
85 <newline/>
86 </xpath>
87 </field>
88 </record>
89
90<!-- Email Template -->
91 <record model="ir.ui.view" id="email_template_form_inherit">
92 <field name="name">email.template.form.inherit</field>
93 <field name="model">email.template</field>
94 <field name="type">form</field>
95 <field name="inherit_id" ref="email_template.email_template_form" />
96 <field name="arch" type="xml">
97 <field name="track_campaign_item" colspan="4" position="after">
98 <field name="ship_mail" colspan="4" />
99 </field>
100 </field>
101 </record>
102
103
104
105 </data>
106</openerp>
107
0108
=== added file 'shipping_api_ups/ups.py'
--- shipping_api_ups/ups.py 1970-01-01 00:00:00 +0000
+++ shipping_api_ups/ups.py 2011-10-06 16:08:52 +0000
@@ -0,0 +1,110 @@
1# -*- coding: utf-8 -*-
2##############################################################################
3#
4# OpenERP, Open Source Management Solution
5# Copyright (C) 2011 NovaPoint Group LLC (<http://www.novapointgroup.com>)
6# Copyright (C) 2004-2010 OpenERP SA (<http://www.openerp.com>)
7#
8# This program is free software: you can redistribute it and/or modify
9# it under the terms of the GNU General Public License as published by
10# the Free Software Foundation, either version 3 of the License, or
11# (at your option) any later version.
12#
13# This program is distributed in the hope that it will be useful,
14# but WITHOUT ANY WARRANTY; without even the implied warranty of
15# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16# GNU General Public License for more details.
17#
18# You should have received a copy of the GNU General Public License
19# along with this program. If not, see <http://www.gnu.org/licenses/>
20#
21##############################################################################
22
23from osv import fields,osv
24import re
25
26
27
28class ups_account_shipping(osv.osv):
29 _name = "ups.account.shipping"
30 _columns = {
31 'name':fields.char('Name', size=64, required=True, select=1),
32 'atten_name':fields.char('AttentionName', size=64, required=True, select=1),
33 'accesslicensenumber': fields.char('AccessLicenseNumber', size= 64, required=True, select=1),
34 'userid': fields.char('UserId',size=64 , required=True, select=1),
35 'password': fields.char('Password', size=64, required=True, select=1),
36 'active':fields.boolean('Active', size=64,),
37 'acc_no':fields.char('Account Number',size=64 , required=True, select=1, help="Shipper's six digit account number."),
38 'tax_id_no':fields.char('Tax Identification Number',size=64 , select=1, help="Shipper's Tax Identification Number."),
39 'logistic_company_id':fields.many2one('logistic.company','Parent Logistic Company'),
40 'ups_shipping_service_ids':fields.one2many('ups.shipping.service.type','ups_account_id','Shipping Service'),
41 'address':fields.many2one('res.partner.address','Shipper Address'),
42 'trademark':fields.char('Trademark', size=1024, select=1),
43 }
44 _defaults={
45 'active':True
46 }
47ups_account_shipping()
48
49
50class ups_account_shipping_service(osv.osv):
51 _name = "ups.shipping.service.type"
52 _rec_name = "description"
53 _columns = {
54 'description': fields.char('Description', size=32, required=True, select=1),
55 'category': fields.char('Category', size=32, select=1),
56 'shipping_service_code': fields.char('Shipping Service Code', size=8, select=1),
57 'rating_service_code': fields.char('Rating Service Code', size=8, select=1),
58 'ups_account_id':fields.many2one('ups.account.shipping','Parent Shipping Account'),
59 }
60ups_account_shipping_service()
61
62
63
64
65class logistic_company(osv.osv):
66 _name = "logistic.company"
67 _inherit="logistic.company"
68 _columns = {
69 'company_id':fields.many2one('res.company','Company'),
70 'ups_shipping_account_ids': fields.one2many('ups.account.shipping','logistic_company_id','Shipping Account'),
71 }
72
73
74 def onchange_shipping_number(self, cr, uid, ids, shipping_no,url,context=None):
75 ret={}
76 if url:
77 b=url[url.rindex('/'):len(url)]
78 b=b.strip('/')
79 if re.match("^[0-9]*$",b):
80 url=url[0:url.rindex('/')]
81 url+=('/'+shipping_no)
82 ret['url']=url
83 return{'value':ret}
84
85logistic_company()
86
87
88class res_company(osv.osv):
89 _inherit = "res.company"
90 _columns = {
91 'logistic_company_ids': fields.one2many('logistic.company','company_id','Shipping Account'),
92 }
93
94res_company()
95
96
97class shipping_move(osv.osv):
98 _inherit = "shipping.move"
99 _columns = {
100 'shipper': fields.many2one('ups.account.shipping','Shipper',help='The specific user ID and shipper. Setup in the company configuration.'),
101 }
102shipping_move()
103
104
105
106
107
108
109
110# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
0\ No newline at end of file111\ No newline at end of file
1112
=== added file 'shipping_api_ups/ups_view.xml'
The diff has been truncated for viewing.

Subscribers

People subscribed via source and target branches

to all changes: