Browse Source

[IMP] improve port on V6

sebastien beau 13 years ago
parent
commit
12714dab5d
  1. 0
      product_gift/__init__.py
  2. 8
      product_gift/__openerp__.py
  3. 3
      product_gift/autoload/magentoerpconnect/1.3.2.4/external.mappinglines.template.csv
  4. 3
      product_gift/autoload/magentoerpconnect/1.5.0.0/external.mappinglines.template.csv
  5. 21
      product_gift/product.py
  6. 8
      product_gift/product_view.xml
  7. 12
      product_gift/sale.py
  8. 11
      product_gift/sale_view.xml
  9. 5
      product_gift/stock.py
  10. 22
      product_gift/stock_view.xml
  11. 3
      product_is_a_gift/mapping/external.mappinglines.template.csv

0
product_is_a_gift/__init__.py → product_gift/__init__.py

8
product_is_a_gift/__terp__.py → product_gift/__openerp__.py

@ -21,16 +21,16 @@
{
'name': 'product_is_a_gift',
'name': 'product_gift',
'version': '0.1',
'category': 'Generic Modules/Others',
'category': 'Generic Modules',
'license': 'AGPL-3',
'description': """empty""",
'description': """This modules add the feature of gift_wraf""",
'author': 'Akretion',
'website': 'http://www.akretion.com/',
'depends': ['sale','product', 'stock'],
'init_xml': [],
'update_xml': [
'update_xml': [
'stock_view.xml',
'product_view.xml',
'sale_view.xml',

3
product_gift/autoload/magentoerpconnect/1.3.2.4/external.mappinglines.template.csv

@ -0,0 +1,3 @@
id,type_id:id,model_id:id,external_field,type,external_type,in_function,out_function
mag_1324_erp_product_is_gift_1,magentoerpconnect.magento1324,sale.model_sale_order,gift_message,in,unicode,"result=[('gift_message',ifield)]",
mag_1324_erp_product_is_gift_2,magentoerpconnect.magento1324,sale.model_sale_order_line,product_options,in,unicode,"result=[('need_gift_wrap', 'Option Cadeau' in ifield)]",

3
product_gift/autoload/magentoerpconnect/1.5.0.0/external.mappinglines.template.csv

@ -0,0 +1,3 @@
id,type_id:id,model_id:id,external_field,type,external_type,in_function,out_function
mag_1500_erp_product_is_gift_1,magentoerpconnect.magento1500,sale.model_sale_order,gift_message,in,unicode,"result=[('gift_message',ifield)]",
mag_1500_erp_product_is_gift_2,magentoerpconnect.magento1500,sale.model_sale_order_line,product_options,in,unicode,"result=[('need_gift_wrap', 'Option Cadeau' in ifield)]",

21
product_is_a_gift/product.py → product_gift/product.py

@ -1,7 +1,7 @@
# -*- encoding: utf-8 -*-
#################################################################################
# #
# product_is_a_gift for OpenERP #
# product_is_a_gift for OpenERP #
# Copyright (C) 2011 Akretion Sébastien BEAU <sebastien.beau@akretion.com> #
# #
# This program is free software: you can redistribute it and/or modify #
@ -26,25 +26,12 @@ import os, sys, imp
class product_product(osv.osv):
_inherit = "product.product"
def init(self, cr):
#load mapping for ecommerce module
print 'launch init'
module_2_template = {'magentoerpconnect' : 'external.mappinglines.template.csv'}
for module in module_2_template:
cr.execute("select id from ir_module_module where name = '%s' and state in ('installed', 'to_update');"%module)
res = cr.fetchall()
print 'res', res
if res:
filename = module_2_template[module]
fp = tools.file_open('product_is_a_gift/mapping/'+ filename)
tools.convert_csv_import(cr, 'product_is_a_gift', filename , fp.read())#, idref=None, mode='init', noupdate=False)
return True
_columns = {
'allow_gift_wrap': fields.boolean('Allow Gift Wrap'),
'allow_gift_wrap': fields.boolean('Allow Gift Wrap', help="Determine if the product can have the option gift wrap on the sale order line"),
}
_defaults = { 'allow_gift_wrap': lambda *a: True,
_defaults = {
'allow_gift_wrap': lambda *a: True,
}
product_product()

8
product_is_a_gift/product_view.xml → product_gift/product_view.xml

@ -2,7 +2,7 @@
<!--
product_is_a_gift for OpenERP
Copyright (C) 2011 Akretion Sébastien BEAU <sebastien.beau@akretion.com>
The licence is in the file __terp__.py
The licence is in the file __openerp__.py
-->
<openerp>
@ -10,15 +10,15 @@
<!-- INHERITED VIEW FOR THE OBJECT : product_product -->
<record id="product_is_a_gift_product_product_view_form" model="ir.ui.view">
<field name="name">product_is_a_gift.product_product.view_form</field>
<record id="product_normal_form_view" model="ir.ui.view">
<field name="name">product_is_a_gift.product_normal_form_view</field>
<field name="model">product.product</field>
<field name="inherit_id" ref="product.product_normal_form_view" />
<field name="type">form</field>
<field eval="15" name="priority"/>
<field name="arch" type="xml">
<data>
<field name="rental" position="after">
<field name="purchase_ok" position="after">
<field name="allow_gift_wrap" />
</field>
</data>

12
product_is_a_gift/sale.py → product_gift/sale.py

@ -1,7 +1,7 @@
# -*- encoding: utf-8 -*-
#################################################################################
# #
# product_is_a_gift for OpenERP #
# product_is_a_gift for OpenERP #
# Copyright (C) 2011 Akretion Sébastien BEAU <sebastien.beau@akretion.com> #
# #
# This program is free software: you can redistribute it and/or modify #
@ -27,33 +27,23 @@ class sale_order(osv.osv):
_inherit = "sale.order"
_columns = {
'gift_message': fields.text('Gift Message'),
}
_defaults = {
}
sale_order()
class sale_order_line(osv.osv):
_inherit = "sale.order.line"
_columns = {
'gift_message': fields.text('Gift Message'),
'need_gift_wrap': fields.boolean('Add Gift Wrap'),
}
_defaults = {
}
sale_order_line()

11
product_is_a_gift/sale_view.xml → product_gift/sale_view.xml

@ -2,7 +2,7 @@
<!--
product_is_a_gift for OpenERP
Copyright (C) 2011 Akretion Sébastien BEAU <sebastien.beau@akretion.com>
The licence is in the file __terp__.py
The licence is in the file __openerp__.py
-->
<openerp>
@ -10,15 +10,14 @@
<!-- INHERITED VIEW FOR THE OBJECT : sale_order -->
<record id="product_is_a_gift_sale_order_view_form" model="ir.ui.view">
<field name="name">product_is_a_gift.sale_order.view_form</field>
<record id="view_order_form" model="ir.ui.view">
<field name="name">product_is_a_gift.view_order_form</field>
<field name="model">sale.order</field>
<field name="inherit_id" ref="sale.view_order_form" />
<field name="type">form</field>
<field name="arch" type="xml">
<data>
<xpath expr="/form/notebook/page[@string='Other data']/separator[@string='Notes']" position="before">
<xpath expr="/form/notebook/page[@string='Other Information']/separator[@string='Notes']" position="before">
<separator string="Gift Message" colspan="4"/>
<field name="gift_message" colspan="4" nolabel="1"/>
</xpath>
@ -36,8 +35,6 @@
<xpath expr="/form/notebook/page/field/tree/field[@name='name']" position="after">
<field name="need_gift_wrap" />
</xpath>
</data>
</field>
</record>

5
product_is_a_gift/stock.py → product_gift/stock.py

@ -31,12 +31,9 @@ class stock_picking(osv.osv):
}
def create(self, cr, uid, vals, context=None):
print 'create picking', vals.get('sale_id', False) and not 'gift_message' in vals
if vals.get('sale_id', False) and not 'gift_message' in vals:
order = self.pool.get('sale.order').browse(cr, uid, vals['sale_id'], context=context)
print 'order.name', order.name, order.gift_message
vals.update({'gift_message' : order.gift_message})
print 'vals', vals
return super(stock_picking, self).create(cr, uid, vals, context=context)
stock_picking()
@ -51,11 +48,9 @@ class stock_move(osv.osv):
}
def create(self, cr, uid, vals, context=None):
print 'create move', vals.get('sale_line_id', False) and not ('gift_message' in vals and 'need_gift_wrap' in vals)
if vals.get('sale_line_id', False) and not ('gift_message' in vals and 'need_gift_wrap' in vals):
line = self.pool.get('sale.order.line').browse(cr, uid, vals['sale_line_id'], context=context)
vals.update({'gift_message' : line.gift_message, 'need_gift_wrap': line.need_gift_wrap})
print 'vals', vals
return super(stock_move, self).create(cr, uid, vals, context=context)

22
product_is_a_gift/stock_view.xml → product_gift/stock_view.xml

@ -2,7 +2,7 @@
<!--
product_is_a_gift for OpenERP
Copyright (C) 2011 Akretion Sébastien BEAU <sebastien.beau@akretion.com>
The licence is in the file __terp__.py
The licence is in the file __openerp__.py
-->
<openerp>
@ -10,10 +10,10 @@
<!-- INHERITED VIEW FOR THE OBJECT : stock_picking -->
<record id="product_is_a_gift_stock_picking_view_picking_out_form" model="ir.ui.view">
<field name="name">product_is_a_gift.stock_picking.view_picking_out_form</field>
<record id="view_picking_form" model="ir.ui.view">
<field name="name">product_is_a_gift.view_picking_form</field>
<field name="model">stock.picking</field>
<field name="inherit_id" ref="stock.view_picking_out_form" />
<field name="inherit_id" ref="stock.view_picking_form" />
<field eval="16" name="priority"/>
<field name="type">form</field>
<field name="arch" type="xml">
@ -25,7 +25,7 @@
</page>
</xpath>
<xpath expr="/form/notebook/page/field/form/separator[@string='Move State']" position="before">
<xpath expr="/form/notebook/page/field/form/label[@string='']" position="before">
<group colspan="4">
<separator string="Gift Option" colspan="4"/>
<field name="need_gift_wrap" />
@ -39,10 +39,10 @@
</record>
<record id="product_is_a_gift_stock_picking_view_picking_delivery_form" model="ir.ui.view">
<field name="name">product_is_a_gift.stock_picking.view_picking_delivery_form</field>
<record id="view_picking_out_form" model="ir.ui.view">
<field name="name">product_is_a_gift.view_picking_out_form</field>
<field name="model">stock.picking</field>
<field name="inherit_id" ref="stock.view_picking_delivery_form" />
<field name="inherit_id" ref="stock.view_picking_out_form" />
<field eval="16" name="priority"/>
<field name="type">form</field>
<field name="arch" type="xml">
@ -54,7 +54,7 @@
</page>
</xpath>
<xpath expr="/form/notebook/page/field/form/separator[@string='Move State']" position="before">
<xpath expr="/form/notebook/page/field/form/label[@string='']" position="before">
<group colspan="4">
<separator string="Gift Option" colspan="4"/>
<field name="need_gift_wrap" />
@ -70,8 +70,8 @@
<!-- INHERITED VIEW FOR THE OBJECT : stock_move -->
<record id="product_is_a_gift_stock_move_view_tree" model="ir.ui.view">
<field name="name">product_is_a_gift.stock_move.view_tree</field>
<record id="view_move_tree" model="ir.ui.view">
<field name="name">product_is_a_gift.view_move_tree</field>
<field name="model">stock.move</field>
<field name="inherit_id" ref="stock.view_move_tree" />
<field eval="16" name="priority"/>

3
product_is_a_gift/mapping/external.mappinglines.template.csv

@ -1,3 +0,0 @@
"id","type_id:id","model_id:id","external_field","type","external_type","in_function","out_function"
"mag_erp_product_is_gift_1","magentoerpconnect.magento1324","sale.model_sale_order","gift_message","in","str","result=[('gift_message',ifield)]",
"mag_erp_product_is_gift_2","magentoerpconnect.magento1324","sale.model_sale_order_line","product_options","in","str","result=[('need_gift_wrap', 'Option Cadeau' in ifield)]",
Loading…
Cancel
Save