clearcorp team mailing list archive
-
clearcorp team
-
Mailing list archive
-
Message #00562
[Merge] lp:~ss-dtic/openerp-costa-rica/6.1-purchase-import into lp:openerp-costa-rica
Miguel Gutierrez has proposed merging lp:~ss-dtic/openerp-costa-rica/6.1-purchase-import into lp:openerp-costa-rica.
Requested reviews:
CLEARCORP drivers (clearcorp-drivers)
For more details, see:
https://code.launchpad.net/~ss-dtic/openerp-costa-rica/6.1-purchase-import/+merge/144126
--
https://code.launchpad.net/~ss-dtic/openerp-costa-rica/6.1-purchase-import/+merge/144126
Your team CLEARCORP development team is subscribed to branch lp:openerp-costa-rica.
=== added directory 'purchase_import'
=== added file 'purchase_import/__init__.py'
--- purchase_import/__init__.py 1970-01-01 00:00:00 +0000
+++ purchase_import/__init__.py 2013-01-21 14:43:26 +0000
@@ -0,0 +1,27 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# OpenERP, Open Source Management Solution
+# Addons modules by SIESA
+# Copyright (C) 2009-TODAY Soluciones Industriales Electromecanicas S.A. (<http://siesacr.com>).
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+
+
+import imports
+import purchase
+import tariff
+import product
=== added file 'purchase_import/__openerp__.py'
--- purchase_import/__openerp__.py 1970-01-01 00:00:00 +0000
+++ purchase_import/__openerp__.py 2013-01-21 14:43:26 +0000
@@ -0,0 +1,46 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# OpenERP, Open Source Management Solution
+# Addons modules by SIESA
+# Copyright (C) 2009-TODAY Soluciones Industriales Electromecanicas S.A. (<http://siesacr.com>).
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+
+
+{
+ 'name': 'Purchase Import',
+ 'version': '1.1',
+ 'category': 'Purchases',
+ 'description': """
+ Add a module that facilitates the purchase of imports, adding tax charges and
+ change the price of the product cost for the total price movement.
+
+ """,
+ 'author': 'SIESA',
+ 'website': 'http://www.siesacr.com',
+ 'depends': ['purchase','product','product_search_improver'],
+ 'data': [
+ 'import_view.xml',
+ 'voucher_view.xml',
+ 'purchase_import_workflow.xml',
+ 'product_view.xml',
+ 'tariff_view.xml',
+ 'import_sequence.xml'
+ ],
+ 'installable': True,
+ 'active': False,
+}
=== added file 'purchase_import/import_sequence.xml'
--- purchase_import/import_sequence.xml 1970-01-01 00:00:00 +0000
+++ purchase_import/import_sequence.xml 2013-01-21 14:43:26 +0000
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="utf-8"?>
+<openerp>
+ <data noupdate="1">
+
+ <!-- Sequences for sale.order -->
+ <record id="ss_seq_type_purchase_import_order" model="ir.sequence.type">
+ <field name="name">Purchase Import Order</field>
+ <field name="code">purchase.import.order</field>
+ </record>
+
+ <record id="ss_seq_purchase_import_order" model="ir.sequence">
+ <field name="name">Purchase Import Order</field>
+ <field name="code">purchase.import.order</field>
+ <field name="prefix">IO</field>
+ <field name="padding">3</field>
+ <field name="company_id" eval="False"/>
+ </record>
+
+ </data>
+</openerp>
=== added file 'purchase_import/import_view.xml'
--- purchase_import/import_view.xml 1970-01-01 00:00:00 +0000
+++ purchase_import/import_view.xml 2013-01-21 14:43:26 +0000
@@ -0,0 +1,138 @@
+<?xml version="1.0" encoding="utf-8"?>
+<openerp>
+ <data>
+
+ <!--Purchase Import Order-->
+ <record id="ss_view_purchase_import_order_filter" model="ir.ui.view">
+ <field name="name">purchase.import.order.list.select</field>
+ <field name="model">purchase.import.order</field>
+ <field name="type">search</field>
+ <field name="arch" type="xml">
+ <search string="Purchase Import">
+ <field name="name"/>
+ <field name="create_date"/>
+ <field name="provenance_id"/>
+ <newline/>
+ <group expand="0" string="Group By..." groups="base.group_extended">
+ <filter string="State" icon="terp-stock_effects-object-colorize" domain="[]" context="{'group_by':'state'}"/>
+ </group>
+ </search>
+ </field>
+ </record>
+
+ <record id="ss_view_purchase_import_order_form" model="ir.ui.view">
+ <field name="name">purchase.import.order.form</field>
+ <field name="model">purchase.import.order</field>
+ <field name="type">form</field>
+ <field name="arch" type="xml">
+ <form string="Purchase Import">
+ <group col="6" colspan="4">
+ <field name="name"/>
+ <field name="create_date"/>
+ <field name="date_arrive"/>
+ </group>
+ <notebook>
+ <page string="Asigned Invoice">
+ <group string="Product Invoices" col="4" colspan="4">
+ <field name="imports_order_id" nolabel="1" domain="[('type', '=', 'in_invoice'),('state','not in',['draft','cancel'])]">
+ <tree string="Products">
+ <field name="number"/>
+ <field name="partner_id"/>
+ <field name="date_invoice"/>
+ <field name="currency_id"/>
+ <field name="amount_total"/>
+ </tree>
+ </field>
+ </group>
+ <group string="Orders" col="3" colspan="2">
+ <newline/>
+ <field name="freight_order_id" domain="[('type', '=', 'in_invoice'),('state','not in',['draft','cancel'])]" /><field name="freight_currency" nolabel="1" readonly="1"/>
+ <field name="tax_order_id" domain="[('type', '=', 'in_invoice'),('state','not in',['draft','cancel'])]"/><field name="taxes_currency" nolabel="1" readonly="1"/>
+ </group>
+
+ <group col="2" string="Freight Details" colspan="2">
+ <newline/>
+ <field name="provenance_id"/>
+ <field name="fob"/>
+ </group>
+ <group col="2" string="Import Total (CRC)" colspan="2">
+ <field name="total_freight"/>
+ <field name="tax_total"/>
+ <field name="total_paid"/>
+
+ </group>
+ <group col="2" string="State" colspan="2">
+ <field name="total_products"/>
+ <group colspan="3">
+ <button name="import_approve" states="draft" string="Approve" icon="gtk-go-forward"/>
+ <button name="import_confirm" states="confirmed" string="Confirme" icon="gtk-go-forward"/>
+ <button name="import_draft" states="cancel" string="Draft" icon="gtk-go-forward"/>
+ <button name="import_cancel" states="confirmed" string="Cancel" icon="gtk-cancel"/>
+ </group>
+ <newline/>
+ <field name="state" widget="statusbar" statusbar_visible="draft,confirmed,done" statusbar_colors='{"cancel":"red","draft":"blue","confirmed":"blue","done":"blue"}' readonly="1"/>
+ </group>
+
+ </page>
+ <page string="Invoice Lines">
+ <group>
+ <field name="lines_id" nolabel="1" readonly="1">
+ <tree string="Products">
+ <field name="name"/>
+ <field name="quantity"/>
+ <field name="uos_id"/>
+ <field name="price_unit"/>
+ <field name="price_subtotal"/>
+ </tree>
+ </field>
+ </group>
+ </page>
+ <page string="Freight">
+ <group>
+ <newline/>
+ <field name="freight" nolabel="1" readonly="1"/>
+ </group>
+ </page>
+ <page string="Tax">
+ <group>
+ <newline/>
+ <field name="taxes" nolabel="1" readonly="1"/>
+ </group>
+ </page>
+ <page string="Voucher">
+ <field colspan="4" mode="form,tree" name="voucher_id" nolabel="1" select="1" height="260"/>
+ </page>
+ <page string="Notes">
+ <field name="note" nolabel="1"/>
+ </page>
+ </notebook>
+ </form>
+ </field>
+ </record>
+ <record model="ir.ui.view" id="ss_view_purchase_import_order_tree">
+ <field name="name">purchase.import.order.tree</field>
+ <field name="model">purchase.import.order</field>
+ <field name="type">tree</field>
+ <field name="arch" type="xml">
+ <tree string="Import Purchase">
+ <field name="name"/>
+ <field name="provenance_id"/>
+ <field name="state"/>
+ </tree>
+ </field>
+ </record>
+ <record model="ir.actions.act_window" id="action_purchase_import_order">
+ <field name="name">Import Purchase</field>
+ <field name="res_model">purchase.import.order</field>
+ <field name="view_type">form</field>
+ </record>
+ <menuitem
+ id="ss_menu_purchase_import_order"
+ name="Import Purchase"
+ parent="purchase.menu_procurement_management"
+ action="action_purchase_import_order"
+ sequence="11"
+ />
+ <!--Purchase Import Order-->
+ </data>
+</openerp>
=== added file 'purchase_import/imports.py'
--- purchase_import/imports.py 1970-01-01 00:00:00 +0000
+++ purchase_import/imports.py 2013-01-21 14:43:26 +0000
@@ -0,0 +1,290 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# OpenERP, Open Source Management Solution
+# Addons modules by SIESA
+# Copyright (C) 2009-TODAY Soluciones Industriales Electromecanicas S.A. (<http://siesacr.com>).
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+from osv import osv, fields
+import decimal_precision as dp
+import math
+import logging
+import re
+from tools.translate import _
+
+class purchase_import_voucher(osv.osv):
+ def _calc_amount_cif(self, cr, uid, ids, prop, unknow_none, unknow_dict):
+ res = {}
+ for voucher in self.browse(cr, uid, ids):
+ res[voucher.id] = voucher.order_id.total_products + voucher.order_id.total_freight
+ return res
+ def _calc_amount_cif_dolars(self, cr, uid, ids, prop, unknow_none, unknow_dict):
+ res = {}
+ for voucher in self.browse(cr, uid, ids):
+ res[voucher.id] = voucher.currency_rate * voucher.cif_real
+ return res
+
+ def button_dummy(self, cr, uid, ids, context=None):
+ return True
+
+ _name = 'purchase.import.voucher'
+ _columns = {
+ 'name': fields.char('Number',size=64),
+ 'date_voucher' : fields.datetime('Create Date'),
+ 'location_id' : fields.many2one('res.partner.address', 'Origin'),
+ 'bidder_id' : fields.many2one('res.partner', 'Bidder'),
+ 'agent_number': fields.char('Agent Number',size=64),
+ 'state_voucher': fields.char('State',size=64),
+ 'regime': fields.char('Regime',size=64),
+ 'importexport': fields.char('Import/Export',size=64),
+ 'mode': fields.char('Mode',size=64),
+ 'type_audit': fields.char('Audit Type',size=64),
+ 'num_bags': fields.float('Bag Number'),
+ 'weight': fields.float('Weight'),
+ 'weight_net': fields.float('Weight Net'),
+ 'cif_real': fields.function(_calc_amount_cif, method=True, string='CIF Real', type='float',help='Cost, insurance, freight'),
+ 'cif_paid': fields.float('CIF Paid', required=True),
+ 'cif_dolars': fields.function(_calc_amount_cif_dolars, method=True, string='CIF USD', type='float',help='(Cost, insurance, freight)* Currency Rate'),
+ 'currency_rate': fields.float('Currency Rate'),
+ 'tax': fields.related('tax_order_id','order_line',type='one2many',relation='purchase.order.line',string='Currency', store=False),
+ 'order_id': fields.many2one('purchase.import.order', 'Order',ondelete='set null', select=True),
+ }
+ _defaults = {
+ }
+purchase_import_voucher()
+
+class purchase_import_order(osv.osv):
+ def create(self, cr, uid, vals, context=None):
+ res = []
+ line_ids = []
+ inv_obj = self.pool.get('account.invoice')
+ vals['name'] = self.pool.get('ir.sequence').get(cr, uid, 'purchase.import.order')
+ invoices = vals['imports_order_id']
+
+ for inv in inv_obj.browse(cr, uid, invoices[0][2]):
+ for line in inv.invoice_line:
+ line_ids.append(line.id)
+
+ vals['lines_id'] = [[6,False,line_ids]]
+
+ res= super(purchase_import_order, self).create(cr, uid, vals, context=context)
+ return res
+
+ def write(self, cr, uid, ids, vals, context=None):
+ res =[]
+ line_ids = []
+ inv_obj = self.pool.get('account.invoice')
+ if 'imports_order_id' in vals:
+ invoices = vals['imports_order_id']
+ for inv in inv_obj.browse(cr, uid, invoices[0][2]):
+ for line in inv.invoice_line:
+ line_ids.append(line.id)
+ vals['lines_id'] = [[6,False,line_ids]]
+
+ res = super(purchase_import_order, self).write(cr, uid, ids, vals, context=context)
+ return res
+
+ def _calc_amount_total(self, cr, uid, ids, prop, unknow_none, unknow_dict):
+ res = {}
+ for order in self.browse(cr, uid, ids):
+ res[order.id] = order.tax_total+ order.total_freight
+ return res
+
+ def _calc_amount_tax(self, cr, uid, ids, prop, unknow_none, unknow_dict):
+ res = {}
+ for order in self.browse(cr, uid, ids):
+ if order.tax_order_id:
+ if order.tax_order_id.currency_id.id == order.tax_order_id.company_id.currency_id.id:
+ currency = 1
+ else:
+ currency = order.tax_order_id.currency_id.rate * order.tax_order_id.company_id.currency_id.rate
+ res[order.id] = order.tax_order_id.amount_untaxed * currency
+
+ else:
+ res[order.id] = 0
+ return res
+ def _calc_amount_prod(self, cr, uid, ids, prop, unknow_none, unknow_dict):
+ res = {}
+ total = 0
+ for imports in self.browse(cr, uid, ids):
+ for order in imports.imports_order_id:
+ if order.currency_id.id == order.company_id.currency_id.id:
+ currency = 1
+ else:
+ currency = order.currency_id.rate * order.company_id.currency_id.rate
+ total = total + (order.amount_untaxed * currency)
+
+ res[imports.id] = total
+ return res
+
+ def _calc_amount_freight(self, cr, uid, ids, prop, unknow_none, unknow_dict):
+ res = {}
+ for order in self.browse(cr, uid, ids):
+ if order.freight_order_id:
+ if order.freight_order_id.currency_id.rate == order.freight_order_id.company_id.currency_id.rate:
+ currency = 1
+ else:
+ currency = order.freight_order_id.currency_id.rate * order.freight_order_id.company_id.currency_id.rate
+
+ res[order.id] = (order.freight_order_id.amount_untaxed + order.fob) * currency
+ else:
+ res[order.id] = 0
+ return res
+ def _calc_amount_insurance(self, cr, uid, ids, prop, unknow_none, unknow_dict):
+ res = {}
+ for order in self.browse(cr, uid, ids):
+ if order.insurance_order_id:
+ if order.insurance_order_id.currency_id.rate == order.insurance_order_id.company_id.currency_id.rate:
+ currency = 1
+ else:
+ currency = order.insurance_order_id.currency_id.rate * order.insurance_order_id.company_id.currency_id.rate
+
+ res[order.id] = order.insurance_order_id.amount_untaxed * currency
+ else:
+ res[order.id] = 0
+ return res
+
+ def action_set_average_price(self, cr, uid, ids, context=None):
+ res = {}
+ total_weight = 0
+ order_tax = 0
+ product_freight = 0
+ product_tax = 0
+ product_insurance = 0
+
+ for imports in self.browse(cr, uid, ids):
+ if imports.cif_paid == 0:
+ raise osv.except_osv(_('Invalid Document!'), _('Update CiF Cost" '))
+
+ if imports.tax_order_id:
+ if imports.tax_order_id.currency_id.id == imports.tax_order_id.company_id.currency_id.id:
+ tax_currency_rate = 1
+ else:
+ tax_currency_rate = imports.tax_order_id.currency_id.rate * imports.tax_order_id.company_id.currency_id.rate
+
+
+ for line in imports.lines_id:
+ uos_ratio = 1
+ if line.uos_id.uom_type =='reference':
+ uos_ratio = 1
+ else:
+ if line.uos_id.uom_type =='bigger':
+ uos_ratio = line.uos_id.factor_inv
+ else:
+ uos_ratio = line.uos_id.factor
+ line_qty = line.quantity * uos_ratio
+
+ product = self.pool.get('product.product').browse(cr, uid, line.product_id.id, context=context)
+ total_weight = total_weight + (line_qty * product.weight)
+ order_tax = order_tax + product.tax_total
+
+ if (line_qty * product.weight) <= 0:
+ raise osv.except_osv(_('Product with weight 0 !'), _('Update the product with part number "%s" ') % (product.part_number))
+
+ if (line_qty * product.tax_total) <= 0:
+ raise osv.except_osv(_('Product without tariff !'), _('Update the product with part number "%s" ') % (product.part_number))
+
+ for order in imports.imports_order_id:
+ if order.currency_id.id == order.company_id.currency_id.id:
+ import_currency_rate = 1
+ else:
+ import_currency_rate = order.currency_id.rate * order.company_id.currency_id.rate
+
+ for line in order.invoice_line:
+ if line.uos_id.uom_type =='reference':
+ uos_ratio = 1
+ else:
+ if line.uos_id.uom_type =='bigger':
+ uos_ratio = line.uos_id.factor_inv
+ else:
+ uos_ratio = line.uos_id.factor
+ line_qty = line.quantity * uos_ratio
+
+
+ product = self.pool.get('product.product').browse(cr, uid, line.product_id.id, context=context)
+
+ #Update price per weight
+ if imports.freight_order_id:
+ product_freight_percentage = product.weight * line_qty / total_weight
+ product_freight = imports.total_freight * product_freight_percentage / line_qty
+
+ #Update price per taxes
+ if imports.tax_order_id:
+ product_tax_percentage = product.tax_total / order_tax
+ product_tax= imports.tax_total * product_tax_percentage / line_qty
+
+
+
+
+ add_cost = (line.price_unit/ uos_ratio * import_currency_rate) + product_freight + product_tax + product_insurance
+
+ if product.qty_available <= line_qty:
+ cost = add_cost
+ else:
+ cost = (add_cost * line_qty + product.standard_price * (product.qty_available - line_qty))/ product.qty_available
+
+ product.write({'costo_fob': line.price_unit}, context=context)
+ product.write({'standard_price': cost}, context=context)
+
+ self.write(cr, uid, ids, {'state': 'done'}, context=context)
+ return True
+
+ _name = 'purchase.import.order'
+ _columns = {
+ 'name': fields.char('Number',size=64,readonly=True),
+ 'fob': fields.float('FoB', required=True),
+
+ 'voucher_id': fields.one2many('purchase.import.voucher', 'order_id', 'Voucher'),
+ 'provenance_id' : fields.many2one('res.country', 'Origin',required=True),
+
+
+ 'imports_order_id': fields.many2many('account.invoice', 'import_invoice_id', 'imports_id', 'invoice_id', 'Product Invoices'),
+
+ 'freight_order_id':fields.many2one('account.invoice', 'Freight Invoice'),
+ 'tax_order_id':fields.many2one('account.invoice', 'Tax Invoice'),
+
+ 'date_arrive' : fields.datetime('Land Date'),
+ 'date_due' : fields.datetime('Due Date'),
+
+ 'total_products': fields.function(_calc_amount_prod, method=True, string='Product total', type='float'),
+
+ 'tax_total': fields.function(_calc_amount_tax, method=True, string='Tax Total', type='float'),
+ 'total_freight': fields.function(_calc_amount_freight, method=True, string='Freight Total', type='float'),
+ 'total_paid': fields.function(_calc_amount_total, method=True, string='Import Total', type='float'),
+
+ 'lines_id': fields.many2many('account.invoice.line', 'import_line_id', 'imports_id', 'line_id', 'Products',readonly=True),
+
+ 'freight': fields.related('freight_order_id','invoice_line',type='one2many',relation='account.invoice.line',string='Freight', store=False),
+ 'freight_currency': fields.related('freight_order_id','currency_id',type='many2one',relation='res.currency',string='Freight Currency', store=False),
+
+ 'taxes': fields.related('tax_order_id','invoice_line',type='one2many',relation='account.invoice.line',string='Taxes', store=False),
+ 'taxes_currency': fields.related('tax_order_id','currency_id',type='many2one',relation='res.currency',string='Tax Currency', store=False),
+
+
+ 'cif_paid': fields.related('voucher_id', 'cif_paid', type='float', string='CIF Paid'),
+ 'cif_real': fields.related('voucher_id', 'cif_real', type='float', string='CIF Real'),
+
+ 'note': fields.text('Notes'),
+ 'create_date' : fields.datetime('Create Date', readonly=True),
+ 'state': fields.selection([('draft', 'Draft'), ('confirmed', 'Confirmed'), ('done', 'Done'), ('cancel', 'Cancel')], 'State', required=True, readonly=True)
+ }
+ _defaults = {
+ 'state': lambda *args: 'draft',
+ }
+
+purchase_import_order()
+
=== added file 'purchase_import/product.py'
--- purchase_import/product.py 1970-01-01 00:00:00 +0000
+++ purchase_import/product.py 2013-01-21 14:43:26 +0000
@@ -0,0 +1,46 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# OpenERP, Open Source Management Solution
+# Addons modules by SIESA
+# Copyright (C) 2009-TODAY Soluciones Industriales Electromecanicas S.A. (<http://siesacr.com>).
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+
+from osv import osv, fields
+import decimal_precision as dp
+import math
+import logging
+import re
+from tools.translate import _
+
+class product_product(osv.osv):
+ _inherit = "product.product"
+ def _calc_amount_tax(self, cr, uid, ids, prop, unknow_none, unknow_dict):
+ res = {}
+ total_tax = 0
+ for product in self.browse(cr, uid, ids):
+ for tax in product.import_taxes:
+ total_tax = total_tax + tax.value
+ res[product.id] = total_tax
+ return res
+
+ _columns = {
+ 'tariff_id' : fields.many2one('purchase.import.tariff', 'Tariff'),
+ 'tax_total': fields.function(_calc_amount_tax, method=True, type='float',help='Taxes from import'),
+ 'import_taxes': fields.related('tariff_id','tax_id',type='one2many',relation='purchase.import.tax'),
+ }
+product_product()
=== added file 'purchase_import/product_view.xml'
--- purchase_import/product_view.xml 1970-01-01 00:00:00 +0000
+++ purchase_import/product_view.xml 2013-01-21 14:43:26 +0000
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="utf-8"?>
+<openerp>
+ <data>
+ <record model="ir.ui.view" id="ss_view_product_form_siesa">
+ <field name="name">product.normal.form</field>
+ <field name="model">product.product</field>
+ <field name="inherit_id" ref="product.product_normal_form_view" />
+ <field name="type">form</field>
+ <field eval="2" name="priority"/>
+ <field name="arch" type="xml">
+ <xpath expr="/form/notebook/page[@string='Information']/group/field[@name='uom_po_id']" position="after">
+ <separator string="Import Tariff" colspan="2" attrs="{'invisible':[('import_ok','!=','1')]}" groups="purchase.group_purchase_manager"/>
+ <field name="tariff_id" string="Tariff" attrs="{'invisible':[('import_ok','!=','1')]}" groups="purchase.group_purchase_manager"/>
+ <field name="tax_total" string="Tariff" attrs="{'invisible':[('import_ok','!=','1')]}" groups="purchase.group_purchase_manager"/>
+ <field name="import_taxes" string="import_taxes" attrs="{'invisible':[('import_ok','!=','1')]}" groups="purchase.group_purchase_manager"/>
+ </xpath>
+ </field>
+ </record>
+ </data>
+</openerp>
=== added file 'purchase_import/purchase.py'
--- purchase_import/purchase.py 1970-01-01 00:00:00 +0000
+++ purchase_import/purchase.py 2013-01-21 14:43:26 +0000
@@ -0,0 +1,41 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# OpenERP, Open Source Management Solution
+# Addons modules by SIESA
+# Copyright (C) 2009-TODAY Soluciones Industriales Electromecanicas S.A. (<http://siesacr.com>).
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+
+import time
+from datetime import datetime
+from dateutil.relativedelta import relativedelta
+
+from osv import osv, fields
+import netsvc
+import pooler
+from tools.translate import _
+import decimal_precision as dp
+from osv.orm import browse_record, browse_null
+import logging
+
+
+class purchase_order_line(osv.osv):
+ _inherit = 'purchase.order.line'
+ _columns = {
+ 'numero_parte': fields.related('product_id','numero_parte',string='Numero Parte',readonly=True,type="char")
+ }
+purchase_order_line()
=== added file 'purchase_import/purchase_import_workflow.xml'
--- purchase_import/purchase_import_workflow.xml 1970-01-01 00:00:00 +0000
+++ purchase_import/purchase_import_workflow.xml 2013-01-21 14:43:26 +0000
@@ -0,0 +1,64 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<openerp>
+ <data>
+ <record id="wkf_import" model="workflow">
+ <field name="name">purchase.import.order.basic</field>
+ <field name="osv">purchase.import.order</field>
+ <field name="on_create">True</field>
+ </record>
+
+ <record id="act_draft" model="workflow.activity">
+ <field name="wkf_id" ref="wkf_import"/>
+ <field name="flow_start">True</field>
+ <field name="name">draft</field>
+ <field name="action">write({'state':'draft'})</field>
+ <field name="kind">function</field>
+ </record>
+
+ <record id="act_done" model="workflow.activity">
+ <field name="wkf_id" ref="wkf_import"/>
+ <field name="name">done</field>
+ <field name="action">action_set_average_price()</field>
+ <field name="kind">function</field>
+ <field name="flow_stop">True</field>
+ </record>
+
+ <record id="act_confirmed" model="workflow.activity">
+ <field name="wkf_id" ref="wkf_import"/>
+ <field name="name">confirm</field>
+ <field name="action">write({'state':'confirmed'})</field>
+ <field name="kind">function</field>
+ </record>
+
+ <record id="act_cancel" model="workflow.activity">
+ <field name="wkf_id" ref="wkf_import"/>
+ <field name="name">cancel</field>
+ <field name="action">write({'state':'cancel'})</field>
+ <field name="kind">function</field>
+ </record>
+
+ <record id="t2" model="workflow.transition">
+ <field name="act_from" ref="act_draft"/>
+ <field name="act_to" ref="act_confirmed"/>
+ <field name="signal">import_approve</field>
+ </record>
+
+ <record id="t7" model="workflow.transition">
+ <field name="act_from" ref="act_confirmed"/>
+ <field name="act_to" ref="act_done"/>
+ <field name="signal">import_confirm</field>
+ </record>
+
+ <record id="t8" model="workflow.transition">
+ <field name="act_from" ref="act_confirmed"/>
+ <field name="act_to" ref="act_cancel"/>
+ <field name="signal">import_cancel</field>
+ </record>
+
+ <record id="t9" model="workflow.transition">
+ <field name="act_from" ref="act_cancel"/>
+ <field name="act_to" ref="act_draft"/>
+ <field name="signal">import_draft</field>
+ </record>
+ </data>
+</openerp>
=== added file 'purchase_import/tariff.py'
--- purchase_import/tariff.py 1970-01-01 00:00:00 +0000
+++ purchase_import/tariff.py 2013-01-21 14:43:26 +0000
@@ -0,0 +1,72 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# OpenERP, Open Source Management Solution
+# Addons modules by SIESA
+# Copyright (C) 2009-TODAY Soluciones Industriales Electromecanicas S.A. (<http://siesacr.com>).
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+
+from osv import osv, fields
+import decimal_precision as dp
+
+import math
+import logging
+import re
+from tools.translate import _
+
+class purchase_import_tariff_category(osv.osv):
+ _name = 'purchase.import.tariff.category'
+ _columns = {
+ 'code': fields.char('Code',size=64),
+ 'name': fields.char('Name',size=64),
+ 'description': fields.char('Description',size=64),
+ }
+purchase_import_tariff_category()
+
+
+class purchase_import_tariff(osv.osv):
+ _name = 'purchase.import.tariff'
+
+ def _calc_amount_tax(self, cr, uid, ids, prop, unknow_none, unknow_dict):
+ res = {}
+ total_tax = 0
+ for tariff in self.browse(cr, uid, ids):
+ for tax in tariff.tax_id:
+ total_tax = total_tax + tax.value
+ res[tariff.id] = total_tax
+ return res
+
+ _columns = {
+ 'name': fields.char('Code',size=64),
+ 'description': fields.char('Description',size=64),
+ 'category' : fields.many2one('purchase.import.tariff.category', 'Category'),
+ 'tax_id': fields.one2many('purchase.import.tax', 'tariff_id', 'Tax'),
+
+ 'tariff_total': fields.function(_calc_amount_tax, method=True, string='Total Tax', type='float',help='Taxes from import'),
+ }
+purchase_import_tariff()
+
+class purchase_import_tax(osv.osv):
+ _name = 'purchase.import.tax'
+ _columns = {
+ 'code': fields.char('Code',size=64, required=True),
+ 'name': fields.char('Name',size=64, required=True),
+ 'description': fields.char('Description',size=64),
+ 'value': fields.float('Value', required=True),
+ 'tariff_id' : fields.many2one('purchase.import.tariff', 'Tariff'),
+ }
+purchase_import_tax()
=== added file 'purchase_import/tariff_view.xml'
--- purchase_import/tariff_view.xml 1970-01-01 00:00:00 +0000
+++ purchase_import/tariff_view.xml 2013-01-21 14:43:26 +0000
@@ -0,0 +1,66 @@
+<?xml version="1.0" encoding="utf-8"?>
+<openerp>
+ <data>
+
+ <!--Purchase Import Voucher-->
+ <record id="ss_view_purchase_import_tariff_filter" model="ir.ui.view">
+ <field name="name">purchase.import.tariff.list.select</field>
+ <field name="model">purchase.import.tariff</field>
+ <field name="type">search</field>
+ <field name="arch" type="xml">
+ <search string="Tariff Search">
+ <field name="name"/>
+ <field name="category"/>
+ </search>
+ </field>
+ </record>
+ <record id="ss_view_purchase_import_tariff_form" model="ir.ui.view">
+ <field name="name">purchase.import.tariff.form</field>
+ <field name="model">purchase.import.tariff</field>
+ <field name="type">form</field>
+ <field name="arch" type="xml">
+ <form string="Import Tariff">
+ <group string="Tariff" col="4" colspan="4">
+ <field name="name"/>
+ <field name="description"/>
+ <field name="category"/>
+ <field name="tariff_total"/>
+ </group>
+ <notebook>
+ <page string="Taxes">
+ <group>
+ <field name="tax_id" nolabel="1" colspan="2"/>
+ </group>
+ </page>
+ </notebook>
+ </form>
+ </field>
+ </record>
+
+ <record model="ir.ui.view" id="ss_view_purchase_import_tariff_tree">
+ <field name="name">purchase.import.tariff.tree</field>
+ <field name="model">purchase.import.tariff</field>
+ <field name="type">tree</field>
+ <field name="arch" type="xml">
+ <tree string="Import Tariff">
+ <field name="name"/>
+ <field name="category"/>
+ <field name="tariff_total"/>
+ </tree>
+ </field>
+ </record>
+ <!--Purchase Import Tariff-->
+ <record model="ir.ui.view" id="ss_view_purchase_import_tax_tree">
+ <field name="name">purchase.import.tax.tree</field>
+ <field name="model">purchase.import.tax</field>
+ <field name="type">tree</field>
+ <field name="arch" type="xml">
+ <tree string="Import Tax">
+ <field name="code"/>
+ <field name="name"/>
+ <field name="value"/>
+ </tree>
+ </field>
+ </record>
+ </data>
+</openerp>
=== added file 'purchase_import/voucher_view.xml'
--- purchase_import/voucher_view.xml 1970-01-01 00:00:00 +0000
+++ purchase_import/voucher_view.xml 2013-01-21 14:43:26 +0000
@@ -0,0 +1,68 @@
+<?xml version="1.0" encoding="utf-8"?>
+<openerp>
+ <data>
+
+ <!--Purchase Import Voucher-->
+ <record id="ss_view_purchase_import_voucher_filter" model="ir.ui.view">
+ <field name="name">purchase.import.voucher.list.select</field>
+ <field name="model">purchase.import.voucher</field>
+ <field name="type">search</field>
+ <field name="arch" type="xml">
+ <search string="Import Voucher Search">
+ <field name="name"/>
+ <field name="bidder_id"/>
+ <field name="agent_number"/>
+ </search>
+ </field>
+ </record>
+ <record id="ss_view_purchase_import_voucher_form" model="ir.ui.view">
+ <field name="name">purchase.import.voucher.form</field>
+ <field name="model">purchase.import.voucher</field>
+ <field name="type">form</field>
+ <field name="arch" type="xml">
+ <form string="Import Voucher">
+ <group string="Voucher" col="2" colspan="2">
+ <field name="name"/>
+ <field name="date_voucher"/>
+ <field name="location_id"/>
+ <field name="bidder_id"/>
+ <field name="agent_number"/>
+ </group>
+ <group string="State" col="2" colspan="2">
+ <field name="state_voucher"/>
+ <field name="regime"/>
+ <field name="importexport"/>
+ <field name="mode"/>
+ </group>
+ <group string="Product" col="2" colspan="2">
+ <field name="type_audit"/>
+ <field name="num_bags"/>
+ <field name="weight"/>
+ <field name="weight_net"/>
+ </group>
+ <group string="Total" col="2" colspan="2">
+ <field name="currency_rate"/>
+ <field name="cif_dolars"/>
+ <field name="cif_real"/>
+ <field name="cif_paid"/>
+ <button name="button_dummy" string="Compute" type="object" icon="gtk-execute"/>
+ </group>
+ </form>
+ </field>
+ </record>
+ <record model="ir.ui.view" id="ss_view_purchase_import_voucher_tree">
+ <field name="name">purchase.import.voucher.tree</field>
+ <field name="model">purchase.import.voucher</field>
+ <field name="type">tree</field>
+ <field name="arch" type="xml">
+ <tree string="Import Voucher">
+ <field name="name"/>
+ <field name="date_voucher"/>
+ <field name="cif_real"/>
+ <field name="cif_paid"/>
+ </tree>
+ </field>
+ </record>
+ <!--Purchase Import Voucher-->
+ </data>
+</openerp>
Follow ups