[IMP] sale modules: Cleaning modules
bzr revid: pso@tinyerp.com-20101022072346-ud8khvwiwhcjpcga
This commit is contained in:
parent
2d17946631
commit
471572043d
|
@ -71,7 +71,6 @@ class crm_make_sale(osv.osv_memory):
|
|||
case_obj = self.pool.get('crm.lead')
|
||||
sale_obj = self.pool.get('sale.order')
|
||||
partner_obj = self.pool.get('res.partner')
|
||||
|
||||
data = context and context.get('active_ids', []) or []
|
||||
|
||||
for make in self.browse(cr, uid, ids, context=context):
|
||||
|
@ -81,7 +80,6 @@ class crm_make_sale(osv.osv_memory):
|
|||
pricelist = partner.property_product_pricelist.id
|
||||
fpos = partner.property_account_position and partner.property_account_position.id or False
|
||||
new_ids = []
|
||||
|
||||
for case in case_obj.browse(cr, uid, data, context=context):
|
||||
if not partner and case.partner_id:
|
||||
partner = case.partner_id
|
||||
|
@ -89,7 +87,6 @@ class crm_make_sale(osv.osv_memory):
|
|||
partner_addr = partner_obj.address_get(cr, uid, [partner.id],
|
||||
['default', 'invoice', 'delivery', 'contact'])
|
||||
pricelist = partner.property_product_pricelist.id
|
||||
|
||||
if False in partner_addr.values():
|
||||
raise osv.except_osv(_('Data Insufficient!'), _('Customer has no addresses defined!'))
|
||||
|
||||
|
@ -105,10 +102,8 @@ class crm_make_sale(osv.osv_memory):
|
|||
'date_order': time.strftime('%Y-%m-%d'),
|
||||
'fiscal_position': fpos,
|
||||
}
|
||||
|
||||
if partner.id:
|
||||
vals['user_id'] = partner.user_id and partner.user_id.id or uid
|
||||
|
||||
new_id = sale_obj.create(cr, uid, vals)
|
||||
case_obj.write(cr, uid, [case.id], {'ref': 'sale.order,%s' % new_id})
|
||||
new_ids.append(new_id)
|
||||
|
@ -118,7 +113,6 @@ class crm_make_sale(osv.osv_memory):
|
|||
|
||||
if make.close:
|
||||
case_obj.case_close(cr, uid, data)
|
||||
|
||||
if not new_ids:
|
||||
return {}
|
||||
if len(new_ids)<=1:
|
||||
|
@ -157,7 +151,7 @@ class crm_make_sale(osv.osv_memory):
|
|||
}
|
||||
_defaults = {
|
||||
'shop_id': _get_shop_id,
|
||||
'close': lambda *args: 1,
|
||||
'close': True,
|
||||
'partner_id': _selectPartner,
|
||||
}
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@ class sale_journal_invoice_type(osv.osv):
|
|||
'name': fields.char('Invoice Type', size=64, required=True),
|
||||
'active': fields.boolean('Active', help="If the active field is set to true, it will allow you to hide the invoice type without removing it."),
|
||||
'note': fields.text('Note'),
|
||||
'invoicing_method': fields.selection([('simple','Non grouped'),('grouped','Grouped')], 'Invoicing method', required=True),
|
||||
'invoicing_method': fields.selection([('simple', 'Non grouped'), ('grouped', 'Grouped')], 'Invoicing method', required=True),
|
||||
}
|
||||
_defaults = {
|
||||
'active': True,
|
||||
|
|
|
@ -21,7 +21,6 @@
|
|||
import time
|
||||
from report import report_sxw
|
||||
|
||||
|
||||
rml_parents = {
|
||||
'tr': 1,
|
||||
'li': 1,
|
||||
|
@ -29,7 +28,6 @@ rml_parents = {
|
|||
'section': 0
|
||||
}
|
||||
|
||||
|
||||
class sale_order_1(report_sxw.rml_parse):
|
||||
def __init__(self, cr, uid, name, context):
|
||||
super(sale_order_1, self).__init__(cr, uid, name, context)
|
||||
|
@ -131,6 +129,7 @@ class sale_order_1(report_sxw.rml_parse):
|
|||
|
||||
result.append(res)
|
||||
return result
|
||||
|
||||
report_sxw.report_sxw('report.sale.order.layout', 'sale.order', 'addons/sale_layout/report/report_sale_layout.rml', parser=sale_order_1)
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
||||
|
|
|
@ -20,10 +20,8 @@
|
|||
#
|
||||
##############################################################################
|
||||
|
||||
from osv import fields,osv
|
||||
from tools import config
|
||||
from osv import fields, osv
|
||||
import decimal_precision as dp
|
||||
from tools.translate import _
|
||||
|
||||
class sale_order_line(osv.osv):
|
||||
|
||||
|
@ -33,9 +31,10 @@ class sale_order_line(osv.osv):
|
|||
res = {}
|
||||
context = context or {}
|
||||
for line in self.browse(cr, uid, ids, context=context):
|
||||
if line.layout_type=='article':
|
||||
if line.layout_type == 'article':
|
||||
return super(sale_order_line, self)._amount_line(cr, uid, ids, field_name, arg, context)
|
||||
return res
|
||||
|
||||
def invoice_line_create(self, cr, uid, ids, context={}):
|
||||
new_ids = []
|
||||
list_seq = []
|
||||
|
@ -52,8 +51,8 @@ class sale_order_line(osv.osv):
|
|||
return invoice_line_ids
|
||||
|
||||
def onchange_sale_order_line_view(self, cr, uid, id, type, context={}, *args):
|
||||
temp ={}
|
||||
temp['value']= {}
|
||||
temp = {}
|
||||
temp['value'] = {}
|
||||
if (not type):
|
||||
return {}
|
||||
if type != 'article':
|
||||
|
@ -68,7 +67,7 @@ class sale_order_line(osv.osv):
|
|||
'discount': 0.0,
|
||||
'invoice_line_tax_id': False,
|
||||
'account_analytic_id': False,
|
||||
'product_uom_qty':0.0,
|
||||
'product_uom_qty': 0.0,
|
||||
},
|
||||
}
|
||||
if type == 'line':
|
||||
|
@ -111,15 +110,15 @@ class sale_order_line(osv.osv):
|
|||
_inherit = "sale.order.line"
|
||||
_columns = {
|
||||
'layout_type': fields.selection([
|
||||
('article','Product'),
|
||||
('title','Title'),
|
||||
('text','Note'),
|
||||
('subtotal','Sub Total'),
|
||||
('line','Separator Line'),
|
||||
('break','Page Break'),]
|
||||
('article', 'Product'),
|
||||
('title', 'Title'),
|
||||
('text', 'Note'),
|
||||
('subtotal', 'Sub Total'),
|
||||
('line', 'Separator Line'),
|
||||
('break', 'Page Break'),]
|
||||
,'Layout Type', select=True, required=True),
|
||||
'sequence': fields.integer('Sequence Number'),
|
||||
'price_unit': fields.float('Unit Price', required=True, digits_compute= dp.get_precision('Sale Price'), readonly=True, states={'draft':[('readonly',False)]}),
|
||||
'price_unit': fields.float('Unit Price', required=True, digits_compute= dp.get_precision('Sale Price'), readonly=True, states={'draft': [('readonly', False)]}),
|
||||
'product_uom_qty': fields.float('Quantity (UoM)', digits=(16,2)),
|
||||
'product_uom': fields.many2one('product.uom', 'Product UoM'),
|
||||
}
|
||||
|
@ -139,7 +138,7 @@ class one2many_mod2(fields.one2many):
|
|||
res = {}
|
||||
for id in ids:
|
||||
res[id] = []
|
||||
ids2 = obj.pool.get(self._obj).search(cr, user, [(self._fields_id,'in',ids),('layout_type','=','article')], limit=self._limit)
|
||||
ids2 = obj.pool.get(self._obj).search(cr, user, [(self._fields_id, 'in', ids), ('layout_type', '=', 'article')], limit=self._limit)
|
||||
for r in obj.pool.get(self._obj)._read_flat(cr, user, ids2, [self._fields_id], context=context, load='_classic_write'):
|
||||
res[r[self._fields_id]].append( r['id'] )
|
||||
return res
|
||||
|
@ -155,8 +154,8 @@ class sale_order(osv.osv):
|
|||
|
||||
_inherit = "sale.order"
|
||||
_columns = {
|
||||
'abstract_line_ids': fields.one2many('sale.order.line', 'order_id', 'Order Lines',readonly=True, states={'draft':[('readonly',False)]}),
|
||||
'order_line': one2many_mod2('sale.order.line', 'order_id', 'Order Lines',readonly=True, states={'draft':[('readonly',False)]}),
|
||||
'abstract_line_ids': fields.one2many('sale.order.line', 'order_id', 'Order Lines', readonly=True, states={'draft': [('readonly', False)]}),
|
||||
'order_line': one2many_mod2('sale.order.line', 'order_id', 'Order Lines', readonly=True, states={'draft': [('readonly', False)]}),
|
||||
}
|
||||
|
||||
sale_order()
|
||||
|
|
|
@ -18,8 +18,7 @@
|
|||
#
|
||||
##############################################################################
|
||||
|
||||
from osv import fields,osv
|
||||
import pooler
|
||||
from osv import fields, osv
|
||||
from tools import config
|
||||
|
||||
class sale_order_line(osv.osv):
|
||||
|
@ -33,7 +32,7 @@ class sale_order_line(osv.osv):
|
|||
lang=lang, update_tax=update_tax, date_order=date_order, packaging=packaging, fiscal_position=fiscal_position, flag=flag)
|
||||
if product:
|
||||
purchase_price = self.pool.get('product.product').browse(cr, uid, product).standard_price
|
||||
res['value'].update({'purchase_price':purchase_price})
|
||||
res['value'].update({'purchase_price': purchase_price})
|
||||
return res
|
||||
|
||||
def _product_margin(self, cr, uid, ids, field_name, arg, context=None):
|
||||
|
@ -42,9 +41,9 @@ class sale_order_line(osv.osv):
|
|||
res[line.id] = 0
|
||||
if line.product_id:
|
||||
if line.purchase_price:
|
||||
res[line.id] = round((line.price_unit*line.product_uos_qty*(100.0-line.discount)/100.0) -(line.purchase_price*line.product_uos_qty),2)
|
||||
res[line.id] = round((line.price_unit*line.product_uos_qty*(100.0-line.discount)/100.0) -(line.purchase_price*line.product_uos_qty), 2)
|
||||
else:
|
||||
res[line.id] = round((line.price_unit*line.product_uos_qty*(100.0-line.discount)/100.0) -(line.product_id.standard_price*line.product_uos_qty),2)
|
||||
res[line.id] = round((line.price_unit*line.product_uos_qty*(100.0-line.discount)/100.0) -(line.product_id.standard_price*line.product_uos_qty), 2)
|
||||
return res
|
||||
|
||||
_columns = {
|
||||
|
@ -75,7 +74,7 @@ class stock_picking(osv.osv):
|
|||
_inherit = 'stock.picking'
|
||||
|
||||
_columns = {
|
||||
'invoice_ids': fields.many2many('account.invoice', 'picking_invoice_rel', 'picking_id', 'invoice_id', 'Invoices', domain=[('type','=','out_invoice')]),
|
||||
'invoice_ids': fields.many2many('account.invoice', 'picking_invoice_rel', 'picking_id', 'invoice_id', 'Invoices', domain=[('type', '=', 'out_invoice')]),
|
||||
}
|
||||
|
||||
def create_invoice(self, cr, uid, ids, *args):
|
||||
|
@ -86,7 +85,7 @@ class stock_picking(osv.osv):
|
|||
picking_obj.write(cr, uid, ids, {'invoice_state': '2binvoiced'})
|
||||
res = picking_obj.action_invoice_create(cr, uid, ids, type='out_invoice', context={})
|
||||
invoice_ids = res.values()
|
||||
picking_obj.write(cr, uid, ids,{'invoice_ids': [[6,0,invoice_ids]]})
|
||||
picking_obj.write(cr, uid, ids, {'invoice_ids': [[6, 0, invoice_ids]]})
|
||||
return True
|
||||
|
||||
stock_picking()
|
||||
|
|
|
@ -64,7 +64,7 @@ class mrp_production(osv.osv):
|
|||
if production.move_prod_id:
|
||||
parent_move_line = get_parent_move(production.move_prod_id)
|
||||
if parent_move_line:
|
||||
move = move_obj.browse(cr,uid,parent_move_line)
|
||||
move = move_obj.browse(cr, uid, parent_move_line)
|
||||
if field_name == 'name':
|
||||
res[production.id] = move.sale_line_id and move.sale_line_id.order_id.name or False
|
||||
if field_name == 'client_order_ref':
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
#
|
||||
##############################################################################
|
||||
|
||||
import time
|
||||
from datetime import datetime
|
||||
from dateutil.relativedelta import relativedelta
|
||||
|
||||
|
@ -39,7 +38,7 @@ class sale_order_dates(osv.osv):
|
|||
if dates_list:
|
||||
res[order.id] = min(dates_list)
|
||||
else:
|
||||
res[order.id] =False
|
||||
res[order.id] = False
|
||||
return res
|
||||
|
||||
def _get_commitment_date(self, cr, uid, ids, name, arg, context={}):
|
||||
|
|
Loading…
Reference in New Issue