Improvement :
* Purchase Order from scheduler: use tax from partner if any. * Report Purchase Order: if address, it uses the name of the company and the address of the customer. Change to use the name of the customer. * Print Packing List: don't display the lines with state=confirmed (only assigned) * When invoice on picking: if I generate invoice on the sale order, it must set the pickings as invoiced * When invoicing from picking: sale order lines stays as 'To be Invoiced' * make new method to get partner property field data same like getting address on partner module and fetch property using this function on needed on onchange partner on sale, purchase module * on delivery module, take taxes from partner if partner has default tax other wise take from delivery product when creation invoice line * on overdue payment report, tel no is display with company invoice address's tel no * Purchase Order from scheduler : assign note of purchase order line with product purchase description * product model : all description should be translatable * fixed bug : on scheduler.py file on mrp module ( got error when select Auto orderpoint on scheduling wizard) * fixed bug : on product available function on stock module ( got error when call it with field_name=None ) bzr revid: hmo@tinyerp.com-20080926102510-nrjwloh0ojkl4hgn
This commit is contained in:
parent
e4df9d7129
commit
abf2c94f97
|
@ -42,6 +42,7 @@ class Overdue(report_sxw.rml_parse):
|
|||
'time' : time,
|
||||
'adr_get' : self._adr_get,
|
||||
'getLines' : self._lines_get,
|
||||
'tel_get' : self._tel_get,
|
||||
})
|
||||
|
||||
def _adr_get(self, partner, type):
|
||||
|
@ -51,6 +52,20 @@ class Overdue(report_sxw.rml_parse):
|
|||
adr_id = addresses and addresses[type] or False
|
||||
return adr_id and res_partner_address.read(self.cr, self.uid, [adr_id])[0] or False
|
||||
|
||||
def _tel_get(self,partner):
|
||||
if not partner:
|
||||
return False
|
||||
res_partner_address = pooler.get_pool(self.cr.dbname).get('res.partner.address')
|
||||
res_partner = pooler.get_pool(self.cr.dbname).get('res.partner')
|
||||
addresses = res_partner.address_get(self.cr, self.uid, [partner.id], ['invoice'])
|
||||
adr_id = addresses and addresses['invoice'] or False
|
||||
if adr_id:
|
||||
adr=res_partner_address.read(self.cr, self.uid, [adr_id])[0]
|
||||
return adr['phone']
|
||||
else:
|
||||
return partner.address and partner.address[0].phone or False
|
||||
return False
|
||||
|
||||
def _lines_get(self, partner):
|
||||
moveline_obj = pooler.get_pool(self.cr.dbname).get('account.move.line')
|
||||
movelines = moveline_obj.search(self.cr, self.uid,
|
||||
|
|
|
@ -110,7 +110,7 @@
|
|||
<para style="P16">
|
||||
<font color="white"> </font>
|
||||
</para>
|
||||
<para style="P16">Would your payment have been carried out after this mail was sent, please consider the present one as void. Do not hesitate to contact our accounting departement at +32 81 81 37 00.</para>
|
||||
<para style="P16">Would your payment have been carried out after this mail was sent, please consider the present one as void. Do not hesitate to contact our accounting departement at [[ tel_get(company.partner_id) ]].</para>
|
||||
<para style="P16">
|
||||
<font color="white"> </font>
|
||||
</para>
|
||||
|
|
|
@ -82,6 +82,25 @@ class stock_picking(osv.osv):
|
|||
if not account_id:
|
||||
account_id = picking.carrier_id.product_id.categ_id\
|
||||
.property_account_income_categ.id
|
||||
|
||||
taxes = self.pool.get('account.tax').browse(cursor, user,
|
||||
[x.id for x in picking.carrier_id.product_id.taxes_id])
|
||||
taxep = None
|
||||
partner_id=picking.address_id.partner_id and picking.address_id.partner_id.id or False
|
||||
if partner_id:
|
||||
taxep_id = self.pool.get('res.partner').property_get(cursor, user,partner_id,property_pref=['property_account_tax']).get('property_account_tax',False)
|
||||
if taxep_id:
|
||||
taxep=self.pool.get('account.tax').browse(cursor, user,taxep_id)
|
||||
if not taxep or not taxep.id:
|
||||
taxes_ids = [x.id for x in picking.carrier_id.product_id.taxes_id]
|
||||
else:
|
||||
res5 = [taxep.id]
|
||||
for t in taxes:
|
||||
if not t.tax_group==taxep.tax_group:
|
||||
res5.append(t.id)
|
||||
taxes_ids = res5
|
||||
|
||||
|
||||
invoice_line_obj.create(cursor, user, {
|
||||
'name': picking.carrier_id.name,
|
||||
'invoice_id': invoice.id,
|
||||
|
@ -90,9 +109,7 @@ class stock_picking(osv.osv):
|
|||
'account_id': account_id,
|
||||
'price_unit': price,
|
||||
'quantity': 1,
|
||||
'invoice_line_tax_id': [(6, 0,
|
||||
[x.id for x in (picking.carrier_id.product_id.taxes_id
|
||||
or [])])],
|
||||
'invoice_line_tax_id': [(6, 0,taxes_ids)],
|
||||
})
|
||||
return result
|
||||
|
||||
|
|
|
@ -65,16 +65,34 @@ def _delivery_set(self, cr, uid, data, context):
|
|||
grid_id = pooler.get_pool(cr.dbname).get('delivery.carrier').grid_get(cr, uid, [data['form']['carrier_id']],order.partner_shipping_id.id)
|
||||
if not grid_id:
|
||||
raise wizard.except_wizard(_('No grid avaible !'), _('No grid matching for this carrier !'))
|
||||
grid = pooler.get_pool(cr.dbname).get('delivery.grid').browse(cr, uid, [grid_id])[0]
|
||||
grid_obj=pooler.get_pool(cr.dbname).get('delivery.grid')
|
||||
grid = grid_obj.browse(cr, uid, [grid_id])[0]
|
||||
|
||||
taxes = pooler.get_pool(cr.dbname).get('account.tax').browse(cr, uid,
|
||||
[x.id for x in grid.carrier_id.product_id.taxes_id])
|
||||
taxep = None
|
||||
partner_id=order.partner_id and order.partner_id.id or False
|
||||
if partner_id:
|
||||
taxep_id = pooler.get_pool(cr.dbname).get('res.partner').property_get(cr, uid,partner_id,property_pref=['property_account_tax']).get('property_account_tax',False)
|
||||
if taxep_id:
|
||||
taxep=pooler.get_pool(cr.dbname).get('account.tax').browse(cr, uid,taxep_id)
|
||||
if not taxep or not taxep.id:
|
||||
taxes_ids = [x.id for x in grid.carrier_id.product_id.taxes_id]
|
||||
else:
|
||||
res5 = [taxep.id]
|
||||
for t in taxes:
|
||||
if not t.tax_group==taxep.tax_group:
|
||||
res5.append(t.id)
|
||||
taxes_ids = res5
|
||||
|
||||
line_obj.create(cr, uid, {
|
||||
'order_id': order.id,
|
||||
'name': grid.carrier_id.name,
|
||||
'product_uom_qty': 1,
|
||||
'product_uom': grid.carrier_id.product_id.uom_id.id,
|
||||
'product_id': grid.carrier_id.product_id.id,
|
||||
'price_unit': grid.get_price(cr, uid, grid.id, order, time.strftime('%Y-%m-%d'), context),
|
||||
'tax_id': [(6,0,[ x.id for x in grid.carrier_id.product_id.taxes_id])],
|
||||
'price_unit': grid_obj.get_price(cr, uid, grid.id, order, time.strftime('%Y-%m-%d'), context),
|
||||
'tax_id': [(6,0,taxes_ids)],
|
||||
'type': 'make_to_stock'
|
||||
})
|
||||
|
||||
|
|
|
@ -947,17 +947,41 @@ class mrp_procurement(osv.osv):
|
|||
|
||||
newdate = DateTime.strptime(procurement.date_planned, '%Y-%m-%d %H:%M:%S') - DateTime.RelativeDateTime(days=procurement.product_id.product_tmpl_id.seller_delay or 0.0)
|
||||
newdate = newdate - DateTime.RelativeDateTime(days=company.po_lead)
|
||||
context.update({'lang':partner.lang})
|
||||
product=self.pool.get('product.product').browse(cr,uid,procurement.product_id.id,context=context)
|
||||
|
||||
line = {
|
||||
'name': procurement.product_id.name,
|
||||
'name': product.name,
|
||||
'product_qty': qty,
|
||||
'product_id': procurement.product_id.id,
|
||||
'product_uom': uom_id,
|
||||
'price_unit': price,
|
||||
'date_planned': newdate.strftime('%Y-%m-%d %H:%M:%S'),
|
||||
'taxes_id': [(6, 0, [x.id for x in procurement.product_id.product_tmpl_id.supplier_taxes_id])],
|
||||
'date_planned': newdate.strftime('%Y-%m-%d %H:%M:%S'),
|
||||
'move_dest_id': res_id,
|
||||
'notes':product.description_purchase,
|
||||
}
|
||||
|
||||
taxes = self.pool.get('account.tax').browse(cr, uid,
|
||||
[x.id for x in procurement.product_id.product_tmpl_id.supplier_taxes_id])
|
||||
taxep = None
|
||||
if partner_id:
|
||||
taxep_id = self.pool.get('res.partner').property_get(cr, uid,partner_id,property_pref=['property_account_supplier_tax']).get('property_account_supplier_tax',False)
|
||||
if taxep_id:
|
||||
taxep=self.pool.get('account.tax').browse(cr, uid,taxep_id)
|
||||
if not taxep or not taxep.id:
|
||||
taxes_ids = [x.id for x in procurement.product_id.product_tmpl_id.supplier_taxes_id]
|
||||
else:
|
||||
res5 = [taxep.id]
|
||||
for t in taxes:
|
||||
if not t.tax_group==taxep.tax_group:
|
||||
res5.append(t.id)
|
||||
taxes_ids = res5
|
||||
|
||||
line.update({
|
||||
'taxes_id':[(6,0,taxes_ids)]
|
||||
})
|
||||
|
||||
|
||||
purchase_id = self.pool.get('purchase.order').create(cr, uid, {
|
||||
'origin': procurement.origin,
|
||||
'partner_id': partner_id,
|
||||
|
|
|
@ -132,7 +132,7 @@ class mrp_procurement(osv.osv):
|
|||
cr.close()
|
||||
return {}
|
||||
|
||||
def create_automatic_op(cr, uid, context=None):
|
||||
def create_automatic_op(self,cr, uid, context=None):
|
||||
if not context:
|
||||
context={}
|
||||
product_obj = self.pool.get('product.product')
|
||||
|
@ -192,7 +192,7 @@ class mrp_procurement(osv.osv):
|
|||
offset = 0
|
||||
ids = [1]
|
||||
if automatic:
|
||||
create_automatic_op(cr, uid, context=context)
|
||||
self.create_automatic_op(cr, uid, context=context)
|
||||
while ids:
|
||||
ids=orderpoint_obj.search(cr,uid,[],offset=offset,limit=100)
|
||||
for op in orderpoint_obj.browse(cr, uid, ids):
|
||||
|
|
|
@ -242,9 +242,9 @@ class product_template(osv.osv):
|
|||
_columns = {
|
||||
'name': fields.char('Name', size=64, required=True, translate=True, select=True),
|
||||
'product_manager': fields.many2one('res.users','Product Manager'),
|
||||
'description': fields.text('Description'),
|
||||
'description_purchase': fields.text('Purchase Description'),
|
||||
'description_sale': fields.text('Sale Description'),
|
||||
'description': fields.text('Description',translate=True),
|
||||
'description_purchase': fields.text('Purchase Description',translate=True),
|
||||
'description_sale': fields.text('Sale Description',translate=True),
|
||||
'type': fields.selection([('product','Stockable Product'),('consu', 'Consumable'),('service','Service')], 'Product Type', required=True, help="Will change the way procurements are processed, consumable are stockable products with infinite stock, or without a stock management in the system."),
|
||||
'supply_method': fields.selection([('produce','Produce'),('buy','Buy')], 'Supply method', required=True, help="Produce will generate production order or tasks, according to the product type. Purchase will trigger purchase orders when requested."),
|
||||
'sale_delay': fields.float('Customer Lead Time', help="This is the average time between the confirmation of the customer order and the delivery of the finnished products. It's the time you promise to your customers."),
|
||||
|
|
|
@ -227,7 +227,8 @@ class purchase_order(osv.osv):
|
|||
if not part:
|
||||
return {'value':{'partner_address_id': False}}
|
||||
addr = self.pool.get('res.partner').address_get(cr, uid, [part], ['default'])
|
||||
pricelist = self.pool.get('res.partner').browse(cr, uid, part).property_product_pricelist_purchase.id
|
||||
pricelist = self.pool.get('res.partner').property_get(cr, uid,
|
||||
part,property_pref=['property_product_pricelist_purchase']).get('property_product_pricelist_purchase',False)
|
||||
return {'value':{'partner_address_id': addr['default'], 'pricelist_id': pricelist}}
|
||||
|
||||
def wkf_approve_order(self, cr, uid, ids):
|
||||
|
@ -424,10 +425,10 @@ class purchase_order_line(osv.osv):
|
|||
return {'value': {'price_unit': 0.0, 'name':'','notes':'', 'product_uom' : False}, 'domain':{'product_uom':[]}}
|
||||
lang=False
|
||||
if partner_id:
|
||||
lang=self.pool.get('res.partner').read(cr, uid, [partner_id])[0]['lang']
|
||||
lang=self.pool.get('res.partner').read(cr, uid, partner_id)['lang']
|
||||
context={'lang':lang}
|
||||
|
||||
prod = self.pool.get('product.product').read(cr, uid, [product], ['supplier_taxes_id','name','seller_delay','uom_po_id','description_purchase'])[0]
|
||||
prod = self.pool.get('product.product').read(cr, uid, product, ['supplier_taxes_id','name','seller_delay','uom_po_id','description_purchase'],context=context)
|
||||
prod_uom_po = prod['uom_po_id'][0]
|
||||
if not uom:
|
||||
uom = prod_uom_po
|
||||
|
@ -444,21 +445,21 @@ class purchase_order_line(osv.osv):
|
|||
res = {'value': {'price_unit': price, 'name':prod_name, 'taxes_id':prod['supplier_taxes_id'], 'date_planned': dt,'notes':prod['description_purchase'], 'product_uom': uom}}
|
||||
domain = {}
|
||||
|
||||
if res['value']['taxes_id']:
|
||||
taxes = self.pool.get('account.tax').browse(cr, uid,
|
||||
[x.id for x in product.supplier_taxes_id])
|
||||
taxep = None
|
||||
if partner_id:
|
||||
taxep = self.pool.get('res.partner').browse(cr, uid,
|
||||
partner_id).property_account_supplier_tax
|
||||
if not taxep or not taxep.id:
|
||||
res['value']['taxes_id'] = [x.id for x in product.taxes_id]
|
||||
else:
|
||||
res5 = [taxep.id]
|
||||
for t in taxes:
|
||||
if not t.tax_group==taxep.tax_group:
|
||||
res5.append(t.id)
|
||||
res['value']['taxes_id'] = res5
|
||||
|
||||
taxes = self.pool.get('account.tax').browse(cr, uid,prod['supplier_taxes_id'])
|
||||
taxep = None
|
||||
if partner_id:
|
||||
taxep_id = self.pool.get('res.partner').property_get(cr, uid,partner_id,property_pref=['property_account_supplier_tax']).get('property_account_supplier_tax',False)
|
||||
if taxep_id:
|
||||
taxep=self.pool.get('account.tax').browse(cr, uid,taxep_id)
|
||||
if not taxep or not taxep.id:
|
||||
res['value']['taxes_id'] = [x.id for x in product.taxes_id]
|
||||
else:
|
||||
res5 = [taxep.id]
|
||||
for t in taxes:
|
||||
if not t.tax_group==taxep.tax_group:
|
||||
res5.append(t.id)
|
||||
res['value']['taxes_id'] = res5
|
||||
|
||||
res2 = self.pool.get('product.uom').read(cr, uid, [uom], ['category_id'])
|
||||
res3 = self.pool.get('product.uom').read(cr, uid, [prod_uom_po], ['category_id'])
|
||||
|
|
|
@ -141,8 +141,8 @@
|
|||
<td>
|
||||
<para style="terp_default_9">[[ repeatIn(o.dest_address_id and [o.dest_address_id] or [],'addr') ]]</para>
|
||||
<para style="terp_default_Bold_9">Shipping address :</para>
|
||||
<para style="terp_default_9">[[ o.partner_id.title or '' ]] [[ o.partner_id.name ]]</para>
|
||||
<para style="terp_default_9">[[ addr.title or '' ]] [[ addr.name ]]</para>
|
||||
<para style="terp_default_9">[[ addr.partner_id.title or '' ]][[ addr.partner_id.name ]]</para>
|
||||
<para style="terp_default_9">[[ addr.title or '' ]][[ addr.name ]]</para>
|
||||
<para style="terp_default_9">[[ addr.street ]]</para>
|
||||
<para style="terp_default_9">[[ addr.street2 or '' ]]</para>
|
||||
<para style="terp_default_9"><font face="Times-Roman">[[ addr.zip or '' ]]</font> [[ addr.city or '' ]]</para>
|
||||
|
|
|
@ -288,8 +288,10 @@ class sale_order(osv.osv):
|
|||
if not part:
|
||||
return {'value':{'partner_invoice_id': False, 'partner_shipping_id':False, 'partner_order_id':False, 'payment_term' : False}}
|
||||
addr = self.pool.get('res.partner').address_get(cr, uid, [part], ['delivery','invoice','contact'])
|
||||
pricelist = self.pool.get('res.partner').browse(cr, uid, part).property_product_pricelist.id
|
||||
payment_term = self.pool.get('res.partner').browse(cr, uid, part).property_payment_term.id
|
||||
pricelist = self.pool.get('res.partner').property_get(cr, uid,
|
||||
part,property_pref=['property_product_pricelist']).get('property_product_pricelist',False)
|
||||
payment_term = self.pool.get('res.partner').property_get(cr, uid,
|
||||
part,property_pref=['property_payment_term']).get('property_payment_term',False)
|
||||
return {'value':{'partner_invoice_id': addr['invoice'], 'partner_order_id':addr['contact'], 'partner_shipping_id':addr['delivery'], 'pricelist_id': pricelist, 'payment_term' : payment_term}}
|
||||
|
||||
def button_dummy(self, cr, uid, ids, context={}):
|
||||
|
@ -357,18 +359,22 @@ class sale_order(osv.osv):
|
|||
for i in o.invoice_ids:
|
||||
if i.state == 'draft':
|
||||
return i.id
|
||||
|
||||
picking_obj=self.pool.get('stock.picking')
|
||||
for val in invoices.values():
|
||||
if grouped:
|
||||
res = self._make_invoice(cr, uid, val[0][0], reduce(lambda x,y: x + y, [l for o,l in val], []))
|
||||
for o,l in val:
|
||||
self.write(cr, uid, [o.id], {'state' : 'progress'})
|
||||
if o.order_policy=='picking':
|
||||
picking_obj.write(cr,uid,map(lambda x:x.id,o.picking_ids),{'invoice_state':'invoiced'})
|
||||
cr.execute('insert into sale_order_invoice_rel (order_id,invoice_id) values (%d,%d)', (o.id, res))
|
||||
else:
|
||||
for order, il in val:
|
||||
res = self._make_invoice(cr, uid, order, il)
|
||||
invoice_ids.append(res)
|
||||
self.write(cr, uid, [order.id], {'state' : 'progress'})
|
||||
if order.order_policy=='picking':
|
||||
picking_obj.write(cr,uid,map(lambda x:x.id,order.picking_ids),{'invoice_state':'invoiced'})
|
||||
cr.execute('insert into sale_order_invoice_rel (order_id,invoice_id) values (%d,%d)', (order.id, res))
|
||||
return res
|
||||
|
||||
|
@ -830,8 +836,10 @@ class sale_order_line(osv.osv):
|
|||
[x.id for x in product_obj.taxes_id])
|
||||
taxep = None
|
||||
if partner_id:
|
||||
taxep = self.pool.get('res.partner').browse(cr, uid,
|
||||
partner_id).property_account_tax
|
||||
taxep_id = self.pool.get('res.partner').property_get(cr, uid,
|
||||
partner_id,property_pref=['property_account_tax']).get('property_account_tax',False)
|
||||
if taxep_id:
|
||||
taxep=self.pool.get('account.tax').browse(cr, uid,taxep_id)
|
||||
if not taxep or not taxep.id:
|
||||
result['tax_id'] = [x.id for x in product_obj.taxes_id]
|
||||
else:
|
||||
|
|
|
@ -132,7 +132,9 @@ class product_product(osv.osv):
|
|||
return res
|
||||
|
||||
def _get_product_available_func(states, what):
|
||||
def _product_available(self, cr, uid, ids, field_names=False, arg=False, context={}):
|
||||
def _product_available(self, cr, uid, ids, field_names=None, arg=False, context={}):
|
||||
if not field_names:
|
||||
field_names=[]
|
||||
context.update({
|
||||
'states':states,
|
||||
'what':what
|
||||
|
|
|
@ -207,7 +207,7 @@
|
|||
</tr>
|
||||
</blockTable>
|
||||
<section>
|
||||
<para style="terp_default_8">[[ repeatIn(picking.move_lines,'move_lines') ]]</para>
|
||||
<para style="terp_default_8">[[ repeatIn([line for line in picking.move_lines if (line.state == 'assigned' )],'move_lines') ]]</para>
|
||||
<blockTable colWidths="59.0,268.0,56.0,51.0,25.0,54.0" style="Move_Line_Contect">
|
||||
<tr>
|
||||
<td>
|
||||
|
|
|
@ -581,11 +581,11 @@ class stock_picking(osv.osv):
|
|||
res = {}
|
||||
sale_line_obj = self.pool.get('sale.order.line')
|
||||
|
||||
for picking in self.browse(cursor, user, ids, context=context):
|
||||
for picking in self.browse(cursor, user, ids, context=context):
|
||||
if picking.invoice_state != '2binvoiced':
|
||||
continue
|
||||
payment_term_id = False
|
||||
partner = picking.address_id.partner_id
|
||||
partner = picking.address_id and picking.address_id.partner_id
|
||||
if type in ('out_invoice', 'out_refund'):
|
||||
account_id = partner.property_account_receivable.id
|
||||
payment_term_id= picking.sale_id.payment_term.id
|
||||
|
@ -712,6 +712,7 @@ class stock_picking(osv.osv):
|
|||
self.write(cursor, user, res.keys(), {
|
||||
'invoice_state': 'invoiced',
|
||||
}, context=context)
|
||||
print res
|
||||
return res
|
||||
|
||||
stock_picking()
|
||||
|
|
|
@ -794,6 +794,7 @@
|
|||
<field name="address_id" select="2"/>
|
||||
<field name="name" select="1" readonly="1"/>
|
||||
<field name="min_date" select="2"/>
|
||||
<field name="invoice_state"/>
|
||||
<field name="backorder_id" select="2" readonly="1"/>
|
||||
</group>
|
||||
<notebook colspan="4">
|
||||
|
|
Loading…
Reference in New Issue