[IMP] merge note&name on purchase lines

bzr revid: fp@openerp.com-20120714205150-c5qjjjyuovbyxac5
This commit is contained in:
Fabien Pinckaers 2012-07-14 22:51:50 +02:00
parent 16cce23c1a
commit 6eaa79227e
7 changed files with 33 additions and 71 deletions

View File

@ -35,7 +35,6 @@ PURCHASE_ORDER_LINE_EDI_STRUCT = {
'product_uom': True,
'price_unit': True,
'product_qty': True,
'notes': True,
# fields used for web preview only - discarded on import
'price_subtotal': True,

View File

@ -687,7 +687,7 @@ class purchase_order(osv.osv):
order_infos['origin'] = (order_infos['origin'] or '') + ' ' + porder.origin
for order_line in porder.order_line:
line_key = make_key(order_line, ('name', 'date_planned', 'taxes_id', 'price_unit', 'notes', 'product_id', 'move_dest_id', 'account_analytic_id'))
line_key = make_key(order_line, ('name', 'date_planned', 'taxes_id', 'price_unit', 'product_id', 'move_dest_id', 'account_analytic_id'))
o_line = order_infos['order_line'].setdefault(line_key, {})
if o_line:
# merge the line with an existing line
@ -806,7 +806,6 @@ class purchase_order_line(osv.osv):
'move_dest_id': fields.many2one('stock.move', 'Reservation Destination', ondelete='set null'),
'price_unit': fields.float('Unit Price', required=True, digits_compute= dp.get_precision('Purchase Price')),
'price_subtotal': fields.function(_amount_line, string='Subtotal', digits_compute= dp.get_precision('Purchase Price')),
'notes': fields.text('Notes'),
'order_id': fields.many2one('purchase.order', 'Order Reference', select=True, required=True, ondelete='cascade'),
'account_analytic_id':fields.many2one('account.analytic.account', 'Analytic Account',),
'company_id': fields.related('order_id','company_id',type='many2one',relation='res.company',string='Company', store=True, readonly=True),
@ -839,15 +838,15 @@ class purchase_order_line(osv.osv):
def onchange_product_uom(self, cr, uid, ids, pricelist_id, product_id, qty, uom_id,
partner_id, date_order=False, fiscal_position_id=False, date_planned=False,
name=False, price_unit=False, notes=False, context=None):
name=False, price_unit=False, context=None):
"""
onchange handler of product_uom.
"""
if not uom_id:
return {'value': {'price_unit': price_unit or 0.0, 'name': name or '', 'notes': notes or'', 'product_uom' : uom_id or False}}
return {'value': {'price_unit': price_unit or 0.0, 'name': name or '', 'product_uom' : uom_id or False}}
return self.onchange_product_id(cr, uid, ids, pricelist_id, product_id, qty, uom_id,
partner_id, date_order=date_order, fiscal_position_id=fiscal_position_id, date_planned=date_planned,
name=name, price_unit=price_unit, notes=notes, context=context)
name=name, price_unit=price_unit, context=context)
def _get_date_planned(self, cr, uid, supplier_info, date_order_str, context=None):
"""Return the datetime value to use as Schedule Date (``date_planned``) for
@ -866,14 +865,14 @@ class purchase_order_line(osv.osv):
def onchange_product_id(self, cr, uid, ids, pricelist_id, product_id, qty, uom_id,
partner_id, date_order=False, fiscal_position_id=False, date_planned=False,
name=False, price_unit=False, notes=False, context=None):
name=False, price_unit=False, context=None):
"""
onchange handler of product_id.
"""
if context is None:
context = {}
res = {'value': {'price_unit': price_unit or 0.0, 'name': name or '', 'notes': notes or '', 'product_uom' : uom_id or False}}
res = {'value': {'price_unit': price_unit or 0.0, 'name': name or '', 'product_uom' : uom_id or False}}
if not product_id:
return res
@ -895,7 +894,10 @@ class purchase_order_line(osv.osv):
lang = res_partner.browse(cr, uid, partner_id).lang
context_partner = {'lang': lang, 'partner_id': partner_id}
product = product_product.browse(cr, uid, product_id, context=context_partner)
res['value'].update({'name': product.name, 'notes': notes or product.description_purchase})
name = product.name
if product.description_purchase:
name += '\n' + product.description_purchase
res['value'].update({'name': name})
# - set a domain on product_uom
res['domain'] = {'product_uom': [('category_id','=',product.uom_id.category_id.id)]}
@ -1049,15 +1051,17 @@ class procurement_order(osv.osv):
taxes_ids = procurement.product_id.product_tmpl_id.supplier_taxes_id
taxes = acc_pos_obj.map_tax(cr, uid, partner.property_account_position, taxes_ids)
name = product.partner_ref
if product.description_purchase:
name += '\n'+ product.description_purchase
line_vals = {
'name': product.partner_ref,
'name': name,
'product_qty': qty,
'product_id': procurement.product_id.id,
'product_uom': uom_id,
'price_unit': price or 0.0,
'date_planned': schedule_date.strftime(DEFAULT_SERVER_DATETIME_FORMAT),
'move_dest_id': res_id,
'notes': product.description_purchase,
'taxes_id': [(6,0,taxes)],
}
name = seq_obj.get(cr, uid, 'purchase.order') or _('PO: %s') % procurement.name

View File

@ -214,7 +214,7 @@
<field name="product_qty"/>
<field name="product_uom" groups="product.group_uom"/>
<field name="price_unit"/>
<field name="price_subtotal"/>
<field name="price_subtotal"/>
</tree>
</field>
<group class="oe_subtotal_footer oe_right">
@ -224,7 +224,7 @@
<button name="button_dummy" states="draft" string="Compute" type="object" icon="gtk-execute" class="oe_inline oe_left"/>
<field name="amount_total"/>
</div>
</group>
</group>
<div class="oe_clear"/>
<label for="notes"/>
<field name="notes"/>
@ -395,31 +395,29 @@
<sheet>
<group>
<group>
<field name="product_id" on_change="onchange_product_id(parent.pricelist_id,product_id,product_qty,product_uom,parent.partner_id, parent.date_order,parent.fiscal_position,date_planned,name,price_unit,notes,context)"/>
<field name="product_id" on_change="onchange_product_id(parent.pricelist_id,product_id,product_qty,product_uom,parent.partner_id, parent.date_order,parent.fiscal_position,date_planned,name,price_unit,context)"/>
<label for="product_qty"/>
<div>
<field name="product_qty" on_change="onchange_product_id(parent.pricelist_id,product_id,product_qty,product_uom,parent.partner_id,parent.date_order,parent.fiscal_position,date_planned,name,price_unit,notes,context)" class="oe_inline"/>
<field name="product_uom" groups="product.group_uom" on_change="onchange_product_uom(parent.pricelist_id,product_id,product_qty,product_uom,parent.partner_id, parent.date_order,parent.fiscal_position,date_planned,name,price_unit,notes,context)" class="oe_inline"/>
<field name="product_qty" on_change="onchange_product_id(parent.pricelist_id,product_id,product_qty,product_uom,parent.partner_id,parent.date_order,parent.fiscal_position,date_planned,name,price_unit,context)" class="oe_inline"/>
<field name="product_uom" groups="product.group_uom" on_change="onchange_product_uom(parent.pricelist_id,product_id,product_qty,product_uom,parent.partner_id, parent.date_order,parent.fiscal_position,date_planned,name,price_unit,context)" class="oe_inline"/>
</div>
<field name="price_unit"/>
<field name="taxes_id" widget="many2many_tags" domain="[('parent_id','=',False),('type_tax_use','!=','sale')]"/>
</group>
<group>
<field name="name"/>
<field name="taxes_id" widget="many2many_tags" domain="[('parent_id','=',False),('type_tax_use','!=','sale')]"/>
<field name="date_planned" widget="date"/>
<field name="account_analytic_id" colspan="2" groups="purchase.group_analytic_accounting" domain="[('parent_id','!=',False)]" />
<field name="company_id" groups="base.group_multi_company" widget="selection"/>
</group>
<group string="Notes" colspan="4">
<field name="notes" nolabel="1" placeholder="Add a note on the purchase line..."/>
</group>
<group string="Invoices" colspan="4">
<field name="invoice_lines" nolabel="1"/>
</group>
<group string="Stock Moves" colspan="4">
<field name="move_ids" nolabel="1"/>
</group>
</group>
<notebook>
<page string="Notes">
<field name="name"/>
</page><page string="Invoices and Receptions">
<field name="invoice_lines"/>
<field name="move_ids"/>
</page>
</notebook>
</sheet>
</form>
</field>
@ -456,14 +454,13 @@
<label for="order_id" class="oe_edit_only"/>
<h1>
<field name="order_id" class="oe_inline"/>
<label string="," attrs="{'invisible':[('date_order','=',False)]}"/>
<label string="," attrs="{'invisible':[('date_order','=',False)]}"/>
<field name="date_order" class="oe_inline"/>
</h1>
<label for="partner_id" class="oe_edit_only"/>
<h2><field name="partner_id"/></h2>
<group>
<group>
<field name="name"/>
<field name="product_id" readonly="1"/>
<label for="product_qty"/>
<div>
@ -473,18 +470,17 @@
<field name="price_unit"/>
</group>
<group>
<field name="taxes_id" widget="many2many_tags"
domain="[('parent_id','=',False),('type_tax_use','!=','sale')]"/>
<field name="date_planned" widget="date" readonly="1"/>
<field name="company_id" groups="base.group_multi_company" widget="selection"/>
<field name="account_analytic_id" colspan="4" groups="purchase.group_analytic_accounting" domain="[('parent_id','!=',False)]"/>
<field name="taxes_id" widget="many2many_tags"
domain="[('parent_id','=',False),('type_tax_use','!=','sale')]"/>
<field name="invoiced"/>
</group>
</group>
<field name="name"/>
<separator string="Manual Invoices"/>
<field name="invoice_lines"/>
<separator string="Notes"/>
<field name="notes"/>
<separator string="Stock Moves"/>
<field name="move_ids"/>
</sheet>

View File

@ -280,36 +280,6 @@
<para style="terp_default_Right_9">[[ formatLang(line.price_subtotal, digits=get_digits(dp='Purchase Price'), currency_obj=o.pricelist_id.currency_id ) ]]</para>
</td>
</tr>
<tr>
<td>
<para style="terp_default_8_Italic">[[ line.notes or removeParentNode('tr') ]]</para>
</td>
<td>
<para style="terp_default_9">
<font color="white"> </font>
</para>
</td>
<td>
<para style="terp_default_Centre_9">
<font color="white"> </font>
</para>
</td>
<td>
<para style="terp_default_Right_9">
<font color="white"> </font>
</para>
</td>
<td>
<para style="terp_default_Right_9">
<font color="white"> </font>
</para>
</td>
<td>
<para style="terp_default_Right_9">
<font color="white"> </font>
</para>
</td>
</tr>
</blockTable>
</section>
<blockTable colWidths="375.0,60.0,100.0" style="Table_All_Total_Detail">

View File

@ -148,11 +148,6 @@
<para style="terp_default_Right_9">[[ (order_line.product_uom and order_line.product_uom.name) or '' ]]</para>
</td>
</tr>
<tr>
<td>
<para style="terp_default_8_italic">[[ format(order_line.notes or removeParentNode('tr')) ]]</para>
</td>
</tr>
</blockTable>
</section>
<para style="terp_default_9">
@ -172,4 +167,4 @@
<para style="terp_default_9">[[ user.signature or '' ]]</para>
</pto>
</story>
</document>
</document>

View File

@ -106,7 +106,6 @@ class stock_picking(osv.osv):
'invoiced': True,
'invoice_lines': [(4, invoice_line_id)],
})
invoice_line_obj.write(cursor, user, [invoice_line_id], {'note': move_line.purchase_line_id.notes,})
return super(stock_picking, self)._invoice_line_hook(cursor, user, move_line, invoice_line_id)
def _invoice_hook(self, cursor, user, picking, invoice_id):

View File

@ -125,7 +125,6 @@ class purchase_line_invoice(osv.osv_memory):
'uos_id': line.product_uom.id,
'product_id': line.product_id.id or False,
'invoice_line_tax_id': [(6, 0, [x.id for x in line.taxes_id])],
'note': line.notes,
'account_analytic_id': line.account_analytic_id and line.account_analytic_id.id or False,
})
purchase_line_obj.write(cr, uid, [line.id], {'invoiced': True, 'invoice_lines': [(4, inv_id)]})