[IMP] improved yml for edi purchase and invoice

bzr revid: han@tinyerp.com-20110916073818-gm51odbv6e9yla02
This commit is contained in:
Hardik Ansodariy (OpenERP) 2011-09-16 13:08:18 +05:30
commit db0891338c
8 changed files with 71 additions and 40 deletions

View File

@ -3,7 +3,7 @@
<data>
<!--Export edi document -->
<record id="ir_actions_server_edi_invoice" model="ir.actions.server">
<field name="code">context.update({'edi_web_invoice_url_view': '%s/edi/view_edi?db=%s&amp;token=%s' %(self.pool.get('ir.config_parameter').get_param(cr, uid, 'web.base.url'),cr.dbname, self.pool.get('ir.edi.document').export_edi(cr, uid, [object], context = context)[0])})
<field name="code">context.update({'edi_web_invoice_url_view': '%s/web/view_edi?db=%s&amp;token=%s' %(self.pool.get('ir.config_parameter').get_param(cr, uid, 'web.base.url'),cr.dbname, self.pool.get('ir.edi.document').export_edi(cr, uid, [object], context = context)[0])})
if not object.partner_id.opt_out: self.pool.get('email.template').send_mail(cr,
uid,
self.pool.get('ir.model.data').get_object_reference(cr, uid, 'account', 'email_template_edi_invoice')[1],

View File

@ -137,7 +137,7 @@
invoice_new = invoice_pool.browse(cr, uid, invoice_id, context=context)
assert invoice_id, 'Invoice is not imported'
-
I Checking the out invoice become in invoice or not after import
I Checking the out invoice become in invoice or not after import
-
!python {model: account.invoice}: |
@ -151,13 +151,20 @@
assert invoice_new.internal_number == False, "internal number is not reset"
assert invoice_new.journal_id.id, "journal id is not selected"
assert invoice_new.type == 'in_invoice', "Imported in voice is not supplier invoice"
assert invoice_new.amount_total == 1010.0, "Amount total is not same"
assert invoice_new.amount_tax == 1000.0, "Amount tax is not same"
assert invoice_new.amount_untaxes == 10.0, "Amount untaxed is not same"
product = ['Medium PC','Basic PC']
assert len(invoice_new.invoice_line) == 2, "invoice lines are not same"
for inv_line in invoice_new.invoice_line:
assert inv_line.account_id.id, "account_id is not taken from product's default"
assert inv_line.product_id.name in ['Medium PC','Basic PC'], "product is not in Invoice line"
if inv_line.name == 'basic pc':
assert inv_line.uos_id.name == "PCE" , "uom is not same"
assert inv_line.price_unit == 10 , "price unit is not same"
assert inv_line.quantity == 1 , "product qty is not same"
assert inv_line.price_subtotal == 10, "price sub total is not same"
elif inv_line.name == 'medium pc':
assert inv_line.uos_id.name == "PCE" , "uom is not same"
assert inv_line.price_unit == 100 , "price unit is not same"
assert inv_line.quantity == 5 , "product qty is not same"
assert inv_line.price_subtotal == 100, "price sub total is not same"
else:
assert 'wrong product imported in invoice lines'
for inv_tax in invoice_new.tax_line:
assert inv_tax.manual, "for tax line manual is not set to True"
assert inv_tax.account_id, "for tax_line default accounts is not picked based on the tax config of the DB where it is imported."

View File

@ -124,9 +124,6 @@ class purchase_order(osv.osv, ir_edi.edi):
if context is None:
context = {}
model = edi_document['__model']
assert model == 'sale.order', _('Could not import purchase order')
edi_document['__model'] = self._name
#import company as a new partner
partner_id = self.edi_import_company(cr, uid, edi_document, context=context)

View File

@ -3,7 +3,7 @@
<data>
<!--Export edi document -->
<record id="ir_actions_server_edi_purchase" model="ir.actions.server">
<field name="code">context.update({'edi_web_purchase_url_view': '%s/edi/view_edi?db=%s&amp;token=%s' %(self.pool.get('ir.config_parameter').get_param(cr, uid, 'web.base.url'),cr.dbname, self.pool.get('ir.edi.document').export_edi(cr, uid, [object], context = context)[0])})
<field name="code">context.update({'edi_web_purchase_url_view': '%s/web/view_edi?db=%s&amp;token=%s' %(self.pool.get('ir.config_parameter').get_param(cr, uid, 'web.base.url'),cr.dbname, self.pool.get('ir.edi.document').export_edi(cr, uid, [object], context = context)[0])})
if not object.partner_id.opt_out: self.pool.get('email.template').send_mail(cr,
uid,
self.pool.get('ir.model.data').get_object_reference(cr, uid, 'purchase', 'email_template_edi_purchase')[1],

View File

@ -25,7 +25,7 @@
- product_id: product.product_product_pc3
product_qty: 10.0
product_uom: 1
price_unit: 200.0
price_unit: 20.0
name: 'medium pc'
date_planned: '2011-08-31'
-
@ -68,7 +68,7 @@
"name": "medium pc",
"product_uom": ["724f93ec-ddd0-11e0-88ec-701a04e25543:product.product_uom_unit", "PCE"],
"sequence": 11,
"price_unit": 200.0,
"price_unit": 20.0,
"__last_update": False,
"__id": "724f93ec-ddd0-11e0-88ec-701a04e25543:724f93ec-ddd0-11e0-88ec-701a04e25543:sale.sale_order_line-LXEqeuI-SSP0",
"product_id": ["724f93ec-ddd0-11e0-88ec-701a04e25543:product.product_product_pc3", "[PC3] Medim PC"]
@ -88,13 +88,13 @@
"date_order": "2011-09-13",
"partner_id": ["724f93ec-ddd0-11e0-88ec-701a04e25543:sale.res_partner_test22", "Junjun wala"],
"__attachments": [],
"__module": "sale",
"__module": "purchase",
"amount_total": 350.0,
"amount_untaxed": 350.0,
"name": "SO008",
"__model": "sale.order",
"__model": "purchase.order",
"__last_update": False,
"company_id": ["724f93ec-ddd0-11e0-88ec-701a04e25543:base.main_company", "OpenERP S.A."],
"company_id": ["724f93ec-ddd0-11e0-88ec-701a04e25543:base.main_company", "Supplier S.A."],
"__version": [6, 1],
"pricelist_id": ["724f93ec-ddd0-11e0-88ec-701a04e25543:product.list0", "Public Pricelist (EUR)"]
}
@ -104,15 +104,23 @@
-
I Checking the sale order become purchase order or not after import
-
!python {model: sale.order}: |
!python {model: purchase.order}: |
ids = self.search(cr, uid, [('partner_id','=','OpenERP S.A.')])
ids = self.search(cr, uid, [('partner_id','=','Supplier S.A.'), ('partner_ref', '=', 'SO008')])
assert ids, 'Order does not have created of party'
order_new = self.browse(cr, uid, ids[0])
assert order_new.pricelist_id.name == 'Public Pricelist' , "Public Price list is not imported"
assert order_new.amount_total == 350, "Amount total is not same"
assert order_new.amount_untaxed == 350, "untaxed amount is not same"
for sale_line in order_new.order_line:
assert sale_line.name in ['basic pc','medium pc'], "name of product is not in order"
assert sale_line.product_id.name in ['Basic PC','Medium PC'], "name of product is not in order"
assert sale_line.date_order == '2011-09-13' , "date of order is not same"
assert len(order_new.order_line) == 2, "Purchase lines are not same"
for purchase_line in order_new.order_line:
if purchase_line.name == 'basic pc':
assert purchase_line.product_uom.name == "PCE" , "uom is not same"
assert purchase_line.price_unit == 150 , "price unit is not same"
assert purchase_line.product_qty == 1 , "product qty is not same"
elif purchase_line.name == 'medium pc':
assert purchase_line.product_uom.name == "PCE" , "uom is not same"
assert purchase_line.price_unit == 20 , "price unit is not same"
assert purchase_line.product_qty == 10 , "product qty is not same"
else:
assert 'wrong product imported in purchase lines'

View File

@ -122,9 +122,6 @@ class sale_order(osv.osv, ir_edi.edi):
if context is None:
context = {}
model = edi_document['__model']
assert model == 'purchase.order', _('Could not import sale order')
edi_document['__model'] = self._name
#import company as a new partner
partner_id = self.edi_import_company(cr, uid, edi_document, context=context)
@ -135,9 +132,11 @@ class sale_order(osv.osv, ir_edi.edi):
order_lines = edi_document['order_line']
for order_line in order_lines:
order_line['product_uom_qty'] = order_line['product_qty']
date_order = datetime.strptime(date_order, "%Y-%m-%d")
date_planned = datetime.strptime(order_line['date_planned'], "%Y-%m-%d")
order_line['delay'] = (date_planned - date_order).days
date_planned = order_line['date_planned']
delay = 0
if date_order and date_planned:
delay = (datetime.strptime(date_planned, "%Y-%m-%d") - datetime.strptime(date_order, "%Y-%m-%d")).days
order_line['delay'] = delay
return super(sale_order,self).edi_import(cr, uid, edi_document, context=context)
sale_order()

View File

@ -3,7 +3,7 @@
<data>
<!--Export edi document -->
<record id="ir_actions_server_edi_sale" model="ir.actions.server">
<field name="code">context.update({'edi_web_sale_url_view': '%s/edi/view_edi?db=%s&amp;token=%s' %(self.pool.get('ir.config_parameter').get_param(cr, uid, 'web.base.url'),cr.dbname, self.pool.get('ir.edi.document').export_edi(cr, uid, [object], context = context)[0])})
<field name="code">context.update({'edi_web_sale_url_view': '%s/web/view_edi?db=%s&amp;token=%s' %(self.pool.get('ir.config_parameter').get_param(cr, uid, 'web.base.url'),cr.dbname, self.pool.get('ir.edi.document').export_edi(cr, uid, [object], context = context)[0])})
if not object.partner_id.opt_out: self.pool.get('email.template').send_email(cr,
uid,
self.pool.get('ir.model.data').get_object_reference(cr, uid, 'sale', 'email_template_edi_sale')[1],

View File

@ -56,19 +56,29 @@
"order_line": [{
"name": "basic pc",
"product_uom": ["5af1272e-dd26-11e0-b65e-701a04e25543:product.product_uom_unit", "PCE"],
"date_planned": "2011-08-31",
"date_planned": "2011-09-30",
"price_unit": 150.0,
"__last_update": False,
"__id": "5af1272e-dd26-11e0-b65e-701a04e25543:purchase.purchase_order_line-AlhsVDZGoKvJ",
"product_qty": 1.0,
"product_id": ["5af1272e-dd26-11e0-b65e-701a04e25543:product.product_product_pc1", "[PC1] Basic PC"]
},
{
"name": "medium pc",
"product_uom": ["5af1272e-dd26-11e0-b65e-701a04e25543:product.product_uom_unit", "PCE"],
"date_planned": "2011-09-15",
"price_unit": 100.0,
"__last_update": False,
"__id": "5af1272e-dd26-11e0-b65e-701a04e25543:purchase.purchase_order_line-AlhsVDZGoKvJ",
"product_qty": 2.0,
"product_id": ["5af1272e-dd26-11e0-b65e-701a04e25543:product.product_product_pc3", "[PC3] Medium PC"]
}],
"partner_address_id": ["5af1272e-dd26-11e0-b65e-701a04e25543:base.res_partner_address_11", "Sebastien LANGE, France, Alencon, 1 place de l'\u00c9glise"],
"__id": "5af1272e-dd26-11e0-b65e-701a04e25543:purchase.purchase_order_test",
"date_order": "2011-09-12",
"partner_id": ["5af1272e-dd26-11e0-b65e-701a04e25543:purchase.res_partner_test20", "jones white"],
"__attachments": [],
"__module": "purchase",
"__module": "sale",
"amount_total": 350.0,
"company_address": {
"phone": "(+32).81.81.37.00",
@ -81,9 +91,9 @@
},
"amount_untaxed": 350.0,
"name": "PO00011",
"__model": "purchase.order",
"__model": "sale.order",
"__last_update": False,
"company_id": ["5af1272e-dd26-11e0-b65e-701a04e25543:base.main_company", "OpenERP S.A."],
"company_id": ["5af1272e-dd26-11e0-b65e-701a04e25543:base.main_company", "Client S.A."],
"__version": [6, 1],
"pricelist_id": ["5af1272e-dd26-11e0-b65e-701a04e25543:product.list0", "Public Pricelist (EUR)"]
}
@ -93,15 +103,25 @@
-
I Checking the sale order become purchase order or not after import
-
!python {model: purchase.order}: |
!python {model: sale.order}: |
ids = self.search(cr, uid, [('partner_id','=','OpenERP S.A.')])
ids = self.search(cr, uid, [('partner_id','=','Client S.A.'), ('client_order_ref', '=', 'PO00011')])
assert ids, 'Order does not have created of party'
order_new = self.browse(cr, uid, ids[0])
assert order_new.pricelist_id.name == 'Public Pricelist' , "Public Price list is not imported"
assert order_new.amount_total == 350, "Amount total is not same"
assert order_new.amount_untaxed == 350, "untaxed amount is not same"
for purchase_line in order_new.order_line:
assert purchase_line.name in ['basic pc','medium pc'], "name of product is not in order"
assert purchase_line.product_id.name in ['Basic PC','Medium PC'], "name of product is not in order"
assert purchase_line.date_planned == '2011-09-13' , "date of planned order is not same"
assert len(order_new.order_line) == 2, "sale lines are not same"
for sale_line in order_new.order_line:
if sale_line.name == 'basic pc':
assert sale_line.delay == 18 , "delay is not same"
assert sale_line.product_uom.name == "PCE" , "uom is not same"
assert sale_line.price_unit == 150 , "price unit is not same"
assert sale_line.product_uom_qty == 1 , "product qty is not same"
elif sale_line.name == 'medium pc':
assert sale_line.delay == 3 , "delay is not same"
assert sale_line.product_uom.name == "PCE" , "uom is not same"
assert sale_line.price_unit == 100 , "price unit is not same"
assert sale_line.product_uom_qty == 2 , "product qty is not same"
else:
assert 'wrong product imported in sale lines'