[IMP] sale: cleaning module
bzr revid: pso@tinyerp.com-20101021093004-lcfd7eiq2tptqutm
This commit is contained in:
parent
5521e773ce
commit
a20240b078
|
@ -30,26 +30,26 @@ class sale_report(osv.osv):
|
||||||
_columns = {
|
_columns = {
|
||||||
'date': fields.date('Date Order', readonly=True),
|
'date': fields.date('Date Order', readonly=True),
|
||||||
'date_confirm': fields.date('Date Confirm', readonly=True),
|
'date_confirm': fields.date('Date Confirm', readonly=True),
|
||||||
'shipped':fields.boolean('Shipped', readonly=True),
|
'shipped': fields.boolean('Shipped', readonly=True),
|
||||||
'shipped_qty_1':fields.integer('Shipped Qty', readonly=True),
|
'shipped_qty_1': fields.integer('Shipped Qty', readonly=True),
|
||||||
'year': fields.char('Year', size=4, readonly=True),
|
'year': fields.char('Year', size=4, readonly=True),
|
||||||
'month':fields.selection([('01','January'), ('02','February'), ('03','March'), ('04','April'),
|
'month': fields.selection([('01', 'January'), ('02', 'February'), ('03', 'March'), ('04', 'April'),
|
||||||
('05','May'), ('06','June'), ('07','July'), ('08','August'), ('09','September'),
|
('05', 'May'), ('06', 'June'), ('07', 'July'), ('08', 'August'), ('09', 'September'),
|
||||||
('10','October'), ('11','November'), ('12','December')], 'Month',readonly=True),
|
('10', 'October'), ('11', 'November'), ('12', 'December')], 'Month', readonly=True),
|
||||||
'day': fields.char('Day', size=128, readonly=True),
|
'day': fields.char('Day', size=128, readonly=True),
|
||||||
'product_id':fields.many2one('product.product', 'Product', readonly=True),
|
'product_id': fields.many2one('product.product', 'Product', readonly=True),
|
||||||
'uom_name': fields.char('Default UoM', size=128, readonly=True),
|
'uom_name': fields.char('Default UoM', size=128, readonly=True),
|
||||||
'product_uom_qty':fields.float('# of Qty', readonly=True),
|
'product_uom_qty': fields.float('# of Qty', readonly=True),
|
||||||
|
|
||||||
'partner_id':fields.many2one('res.partner', 'Partner', readonly=True),
|
'partner_id': fields.many2one('res.partner', 'Partner', readonly=True),
|
||||||
'shop_id':fields.many2one('sale.shop', 'Shop', readonly=True),
|
'shop_id': fields.many2one('sale.shop', 'Shop', readonly=True),
|
||||||
'company_id':fields.many2one('res.company', 'Company', readonly=True),
|
'company_id': fields.many2one('res.company', 'Company', readonly=True),
|
||||||
'user_id':fields.many2one('res.users', 'Salesman', readonly=True),
|
'user_id': fields.many2one('res.users', 'Salesman', readonly=True),
|
||||||
'price_total':fields.float('Total Price', readonly=True),
|
'price_total': fields.float('Total Price', readonly=True),
|
||||||
'delay':fields.float('Commitment Delay', digits=(16,2), readonly=True),
|
'delay': fields.float('Commitment Delay', digits=(16,2), readonly=True),
|
||||||
'price_average':fields.float('Average Price', readonly=True,group_operator="avg"),
|
'price_average': fields.float('Average Price', readonly=True,group_operator="avg"),
|
||||||
'categ_id': fields.many2one('product.category','Category of Product', readonly=True),
|
'categ_id': fields.many2one('product.category','Category of Product', readonly=True),
|
||||||
'nbr':fields.integer('# of Lines', readonly=True),
|
'nbr': fields.integer('# of Lines', readonly=True),
|
||||||
'state': fields.selection([
|
'state': fields.selection([
|
||||||
('draft', 'Quotation'),
|
('draft', 'Quotation'),
|
||||||
('waiting_date', 'Waiting Schedule'),
|
('waiting_date', 'Waiting Schedule'),
|
||||||
|
@ -124,5 +124,4 @@ class sale_report(osv.osv):
|
||||||
""")
|
""")
|
||||||
sale_report()
|
sale_report()
|
||||||
|
|
||||||
|
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||||
|
|
||||||
|
|
|
@ -65,7 +65,7 @@ class sale_order(osv.osv):
|
||||||
'shipped': False,
|
'shipped': False,
|
||||||
'invoice_ids': [],
|
'invoice_ids': [],
|
||||||
'picking_ids': [],
|
'picking_ids': [],
|
||||||
'date_confirm':False,
|
'date_confirm': False,
|
||||||
'name': self.pool.get('ir.sequence').get(cr, uid, 'sale.order'),
|
'name': self.pool.get('ir.sequence').get(cr, uid, 'sale.order'),
|
||||||
})
|
})
|
||||||
return super(sale_order, self).copy(cr, uid, id, default, context=context)
|
return super(sale_order, self).copy(cr, uid, id, default, context=context)
|
||||||
|
@ -345,7 +345,6 @@ class sale_order(osv.osv):
|
||||||
payment_term = part.property_payment_term and part.property_payment_term.id or False
|
payment_term = part.property_payment_term and part.property_payment_term.id or False
|
||||||
fiscal_position = part.property_account_position and part.property_account_position.id or False
|
fiscal_position = part.property_account_position and part.property_account_position.id or False
|
||||||
dedicated_salesman = part.user_id and part.user_id.id or uid
|
dedicated_salesman = part.user_id and part.user_id.id or uid
|
||||||
|
|
||||||
val = {
|
val = {
|
||||||
'partner_invoice_id': addr['invoice'],
|
'partner_invoice_id': addr['invoice'],
|
||||||
'partner_order_id': addr['contact'],
|
'partner_order_id': addr['contact'],
|
||||||
|
@ -354,10 +353,8 @@ class sale_order(osv.osv):
|
||||||
'fiscal_position': fiscal_position,
|
'fiscal_position': fiscal_position,
|
||||||
'user_id': dedicated_salesman,
|
'user_id': dedicated_salesman,
|
||||||
}
|
}
|
||||||
|
|
||||||
if pricelist:
|
if pricelist:
|
||||||
val['pricelist_id'] = pricelist
|
val['pricelist_id'] = pricelist
|
||||||
|
|
||||||
return {'value': val}
|
return {'value': val}
|
||||||
|
|
||||||
def shipping_policy_change(self, cr, uid, ids, policy, context=None):
|
def shipping_policy_change(self, cr, uid, ids, policy, context=None):
|
||||||
|
@ -375,7 +372,7 @@ class sale_order(osv.osv):
|
||||||
def write(self, cr, uid, ids, vals, context=None):
|
def write(self, cr, uid, ids, vals, context=None):
|
||||||
if context is None:
|
if context is None:
|
||||||
context = {}
|
context = {}
|
||||||
if 'order_policy' in vals:
|
if vals.get('order_policy', False):
|
||||||
if vals['order_policy'] == 'prepaid':
|
if vals['order_policy'] == 'prepaid':
|
||||||
vals.update({'invoice_quantity': 'order'})
|
vals.update({'invoice_quantity': 'order'})
|
||||||
elif vals['order_policy'] == 'picking':
|
elif vals['order_policy'] == 'picking':
|
||||||
|
@ -385,7 +382,7 @@ class sale_order(osv.osv):
|
||||||
def create(self, cr, uid, vals, context=None):
|
def create(self, cr, uid, vals, context=None):
|
||||||
if context is None:
|
if context is None:
|
||||||
context = {}
|
context = {}
|
||||||
if 'order_policy' in vals:
|
if vals.get('order_policy', False):
|
||||||
if vals['order_policy'] == 'prepaid':
|
if vals['order_policy'] == 'prepaid':
|
||||||
vals.update({'invoice_quantity': 'order'})
|
vals.update({'invoice_quantity': 'order'})
|
||||||
if vals['order_policy'] == 'picking':
|
if vals['order_policy'] == 'picking':
|
||||||
|
@ -418,10 +415,7 @@ class sale_order(osv.osv):
|
||||||
raise osv.except_osv(_('Error !'),
|
raise osv.except_osv(_('Error !'),
|
||||||
_('There is no sale journal defined for this company: "%s" (id:%d)') % (order.company_id.name, order.company_id.id))
|
_('There is no sale journal defined for this company: "%s" (id:%d)') % (order.company_id.name, order.company_id.id))
|
||||||
a = order.partner_id.property_account_receivable.id
|
a = order.partner_id.property_account_receivable.id
|
||||||
if order.payment_term:
|
pay_term = order.payment_term and order.payment_term.id or False
|
||||||
pay_term = order.payment_term.id
|
|
||||||
else:
|
|
||||||
pay_term = False
|
|
||||||
invoiced_sale_line_ids = self.pool.get('sale.order.line').search(cr, uid, [('order_id', '=', order.id), ('invoiced', '=', True)], context=context)
|
invoiced_sale_line_ids = self.pool.get('sale.order.line').search(cr, uid, [('order_id', '=', order.id), ('invoiced', '=', True)], context=context)
|
||||||
from_line_invoice_ids = []
|
from_line_invoice_ids = []
|
||||||
for invoiced_sale_line_id in self.pool.get('sale.order.line').browse(cr, uid, invoiced_sale_line_ids, context=context):
|
for invoiced_sale_line_id in self.pool.get('sale.order.line').browse(cr, uid, invoiced_sale_line_ids, context=context):
|
||||||
|
@ -450,7 +444,7 @@ class sale_order(osv.osv):
|
||||||
'fiscal_position': order.fiscal_position.id or order.partner_id.property_account_position.id,
|
'fiscal_position': order.fiscal_position.id or order.partner_id.property_account_position.id,
|
||||||
'date_invoice': context.get('date_invoice',False),
|
'date_invoice': context.get('date_invoice',False),
|
||||||
'company_id': order.company_id.id,
|
'company_id': order.company_id.id,
|
||||||
'user_id':order.user_id and order.user_id.id or False
|
'user_id': order.user_id and order.user_id.id or False
|
||||||
}
|
}
|
||||||
inv.update(self._inv_get(cr, uid, order))
|
inv.update(self._inv_get(cr, uid, order))
|
||||||
inv_id = inv_obj.create(cr, uid, inv, context=context)
|
inv_id = inv_obj.create(cr, uid, inv, context=context)
|
||||||
|
@ -485,11 +479,10 @@ class sale_order(osv.osv):
|
||||||
'res_model': 'account.invoice',
|
'res_model': 'account.invoice',
|
||||||
'context': "{'type':'out_invoice'}",
|
'context': "{'type':'out_invoice'}",
|
||||||
'type': 'ir.actions.act_window',
|
'type': 'ir.actions.act_window',
|
||||||
'nodestroy' :True,
|
'nodestroy': True,
|
||||||
'target': 'current',
|
'target': 'current',
|
||||||
'res_id': inv_ids and inv_ids[0] or False,
|
'res_id': inv_ids and inv_ids[0] or False,
|
||||||
}
|
}
|
||||||
|
|
||||||
return result
|
return result
|
||||||
|
|
||||||
def action_invoice_create(self, cr, uid, ids, grouped=False, states=['confirmed', 'done', 'exception'], date_inv = False, context=None):
|
def action_invoice_create(self, cr, uid, ids, grouped=False, states=['confirmed', 'done', 'exception'], date_inv = False, context=None):
|
||||||
|
@ -539,7 +532,6 @@ class sale_order(osv.osv):
|
||||||
if order.order_policy == 'picking':
|
if order.order_policy == 'picking':
|
||||||
picking_obj.write(cr, uid, map(lambda x: x.id, order.picking_ids), {'invoice_state': 'invoiced'})
|
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 (%s,%s)', (order.id, res))
|
cr.execute('insert into sale_order_invoice_rel (order_id,invoice_id) values (%s,%s)', (order.id, res))
|
||||||
|
|
||||||
return res
|
return res
|
||||||
|
|
||||||
def action_invoice_cancel(self, cr, uid, ids, context=None):
|
def action_invoice_cancel(self, cr, uid, ids, context=None):
|
||||||
|
@ -591,7 +583,6 @@ class sale_order(osv.osv):
|
||||||
#
|
#
|
||||||
if order.state == 'invoice_except':
|
if order.state == 'invoice_except':
|
||||||
self.write(cr, uid, [order.id], {'state': 'progress'}, context=context)
|
self.write(cr, uid, [order.id], {'state': 'progress'}, context=context)
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def action_cancel(self, cr, uid, ids, context=None):
|
def action_cancel(self, cr, uid, ids, context=None):
|
||||||
|
@ -858,29 +849,29 @@ class sale_order_line(osv.osv):
|
||||||
_description = 'Sale Order Line'
|
_description = 'Sale Order Line'
|
||||||
_columns = {
|
_columns = {
|
||||||
'order_id': fields.many2one('sale.order', 'Order Reference', required=True, ondelete='cascade', select=True, readonly=True, states={'draft':[('readonly',False)]}),
|
'order_id': fields.many2one('sale.order', 'Order Reference', required=True, ondelete='cascade', select=True, readonly=True, states={'draft':[('readonly',False)]}),
|
||||||
'name': fields.char('Description', size=256, required=True, select=True, readonly=True, states={'draft':[('readonly',False)]}),
|
'name': fields.char('Description', size=256, required=True, select=True, readonly=True, states={'draft': [('readonly', False)]}),
|
||||||
'sequence': fields.integer('Sequence', help="Gives the sequence order when displaying a list of sale order lines."),
|
'sequence': fields.integer('Sequence', help="Gives the sequence order when displaying a list of sale order lines."),
|
||||||
'delay': fields.float('Delivery Lead Time', required=True, help="Number of days between the order confirmation the the shipping of the products to the customer", readonly=True, states={'draft':[('readonly',False)]}),
|
'delay': fields.float('Delivery Lead Time', required=True, help="Number of days between the order confirmation the the shipping of the products to the customer", readonly=True, states={'draft': [('readonly', False)]}),
|
||||||
'product_id': fields.many2one('product.product', 'Product', domain=[('sale_ok', '=', True)], change_default=True),
|
'product_id': fields.many2one('product.product', 'Product', domain=[('sale_ok', '=', True)], change_default=True),
|
||||||
'invoice_lines': fields.many2many('account.invoice.line', 'sale_order_line_invoice_rel', 'order_line_id', 'invoice_id', 'Invoice Lines', readonly=True),
|
'invoice_lines': fields.many2many('account.invoice.line', 'sale_order_line_invoice_rel', 'order_line_id', 'invoice_id', 'Invoice Lines', readonly=True),
|
||||||
'invoiced': fields.boolean('Invoiced', readonly=True),
|
'invoiced': fields.boolean('Invoiced', readonly=True),
|
||||||
'procurement_id': fields.many2one('procurement.order', 'Procurement'),
|
'procurement_id': fields.many2one('procurement.order', 'Procurement'),
|
||||||
'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)]}),
|
||||||
'price_subtotal': fields.function(_amount_line, method=True, string='Subtotal', digits_compute= dp.get_precision('Sale Price')),
|
'price_subtotal': fields.function(_amount_line, method=True, string='Subtotal', digits_compute= dp.get_precision('Sale Price')),
|
||||||
'tax_id': fields.many2many('account.tax', 'sale_order_tax', 'order_line_id', 'tax_id', 'Taxes', readonly=True, states={'draft':[('readonly',False)]}),
|
'tax_id': fields.many2many('account.tax', 'sale_order_tax', 'order_line_id', 'tax_id', 'Taxes', readonly=True, states={'draft': [('readonly', False)]}),
|
||||||
'type': fields.selection([('make_to_stock', 'from stock'), ('make_to_order', 'on order')], 'Procurement Method', required=True, readonly=True, states={'draft':[('readonly',False)]}),
|
'type': fields.selection([('make_to_stock', 'from stock'), ('make_to_order', 'on order')], 'Procurement Method', required=True, readonly=True, states={'draft': [('readonly', False)]}),
|
||||||
'property_ids': fields.many2many('mrp.property', 'sale_order_line_property_rel', 'order_id', 'property_id', 'Properties', readonly=True, states={'draft':[('readonly',False)]}),
|
'property_ids': fields.many2many('mrp.property', 'sale_order_line_property_rel', 'order_id', 'property_id', 'Properties', readonly=True, states={'draft': [('readonly', False)]}),
|
||||||
'address_allotment_id': fields.many2one('res.partner.address', 'Allotment Partner'),
|
'address_allotment_id': fields.many2one('res.partner.address', 'Allotment Partner'),
|
||||||
'product_uom_qty': fields.float('Quantity (UoM)', digits=(16, 2), required=True, readonly=True, states={'draft':[('readonly',False)]}),
|
'product_uom_qty': fields.float('Quantity (UoM)', digits=(16, 2), required=True, readonly=True, states={'draft': [('readonly', False)]}),
|
||||||
'product_uom': fields.many2one('product.uom', 'Unit of Measure ', required=True, readonly=True, states={'draft':[('readonly',False)]}),
|
'product_uom': fields.many2one('product.uom', 'Unit of Measure ', required=True, readonly=True, states={'draft': [('readonly', False)]}),
|
||||||
'product_uos_qty': fields.float('Quantity (UoS)', readonly=True, states={'draft':[('readonly',False)]}),
|
'product_uos_qty': fields.float('Quantity (UoS)', readonly=True, states={'draft': [('readonly', False)]}),
|
||||||
'product_uos': fields.many2one('product.uom', 'Product UoS'),
|
'product_uos': fields.many2one('product.uom', 'Product UoS'),
|
||||||
'product_packaging': fields.many2one('product.packaging', 'Packaging'),
|
'product_packaging': fields.many2one('product.packaging', 'Packaging'),
|
||||||
'move_ids': fields.one2many('stock.move', 'sale_line_id', 'Inventory Moves', readonly=True),
|
'move_ids': fields.one2many('stock.move', 'sale_line_id', 'Inventory Moves', readonly=True),
|
||||||
'discount': fields.float('Discount (%)', digits=(16, 2), readonly=True, states={'draft':[('readonly',False)]}),
|
'discount': fields.float('Discount (%)', digits=(16, 2), readonly=True, states={'draft': [('readonly', False)]}),
|
||||||
'number_packages': fields.function(_number_packages, method=True, type='integer', string='Number Packages'),
|
'number_packages': fields.function(_number_packages, method=True, type='integer', string='Number Packages'),
|
||||||
'notes': fields.text('Notes'),
|
'notes': fields.text('Notes'),
|
||||||
'th_weight': fields.float('Weight', readonly=True, states={'draft':[('readonly',False)]}),
|
'th_weight': fields.float('Weight', readonly=True, states={'draft': [('readonly', False)]}),
|
||||||
'state': fields.selection([('draft', 'Draft'),('confirmed', 'Confirmed'),('done', 'Done'),('cancel', 'Cancelled'),('exception', 'Exception')], 'State', required=True, readonly=True,
|
'state': fields.selection([('draft', 'Draft'),('confirmed', 'Confirmed'),('done', 'Done'),('cancel', 'Cancelled'),('exception', 'Exception')], 'State', required=True, readonly=True,
|
||||||
help='* The \'Draft\' state is set when the related sale order in draft state. \
|
help='* The \'Draft\' state is set when the related sale order in draft state. \
|
||||||
\n* The \'Confirmed\' state is set when the related sale order is confirmed. \
|
\n* The \'Confirmed\' state is set when the related sale order is confirmed. \
|
||||||
|
@ -889,7 +880,7 @@ class sale_order_line(osv.osv):
|
||||||
\n* The \'Cancelled\' state is set when a user cancel the sale order related.'),
|
\n* The \'Cancelled\' state is set when a user cancel the sale order related.'),
|
||||||
'order_partner_id': fields.related('order_id', 'partner_id', type='many2one', relation='res.partner', string='Customer'),
|
'order_partner_id': fields.related('order_id', 'partner_id', type='many2one', relation='res.partner', string='Customer'),
|
||||||
'salesman_id':fields.related('order_id', 'user_id', type='many2one', relation='res.users', string='Salesman'),
|
'salesman_id':fields.related('order_id', 'user_id', type='many2one', relation='res.users', string='Salesman'),
|
||||||
'company_id': fields.related('order_id', 'company_id', type='many2one', relation='res.company', string='Company', store=True, readonly=True, states={'draft':[('readonly',False)]}),
|
'company_id': fields.related('order_id', 'company_id', type='many2one', relation='res.company', string='Company', store=True, readonly=True, states={'draft': [('readonly', False)]}),
|
||||||
}
|
}
|
||||||
_order = 'sequence, id desc'
|
_order = 'sequence, id desc'
|
||||||
_defaults = {
|
_defaults = {
|
||||||
|
@ -1049,7 +1040,6 @@ class sale_order_line(osv.osv):
|
||||||
return {'value': {'th_weight': 0, 'product_packaging': False,
|
return {'value': {'th_weight': 0, 'product_packaging': False,
|
||||||
'product_uos_qty': qty}, 'domain': {'product_uom': [],
|
'product_uos_qty': qty}, 'domain': {'product_uom': [],
|
||||||
'product_uos': []}}
|
'product_uos': []}}
|
||||||
|
|
||||||
if not date_order:
|
if not date_order:
|
||||||
date_order = time.strftime('%Y-%m-%d')
|
date_order = time.strftime('%Y-%m-%d')
|
||||||
|
|
||||||
|
@ -1081,7 +1071,6 @@ class sale_order_line(osv.osv):
|
||||||
uom2 = product_uom_obj.browse(cr, uid, uom)
|
uom2 = product_uom_obj.browse(cr, uid, uom)
|
||||||
if product_obj.uom_id.category_id.id != uom2.category_id.id:
|
if product_obj.uom_id.category_id.id != uom2.category_id.id:
|
||||||
uom = False
|
uom = False
|
||||||
|
|
||||||
if uos:
|
if uos:
|
||||||
if product_obj.uos_id:
|
if product_obj.uos_id:
|
||||||
uos2 = product_uom_obj.browse(cr, uid, uos)
|
uos2 = product_uom_obj.browse(cr, uid, uos)
|
||||||
|
@ -1142,10 +1131,7 @@ class sale_order_line(osv.osv):
|
||||||
max(0,product_obj.virtual_available), product_obj.uom_id.name,
|
max(0,product_obj.virtual_available), product_obj.uom_id.name,
|
||||||
max(0,product_obj.qty_available), product_obj.uom_id.name)
|
max(0,product_obj.qty_available), product_obj.uom_id.name)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
# get unit price
|
# get unit price
|
||||||
|
|
||||||
if not pricelist:
|
if not pricelist:
|
||||||
warning = {
|
warning = {
|
||||||
'title': 'No Pricelist !',
|
'title': 'No Pricelist !',
|
||||||
|
@ -1189,12 +1175,11 @@ class sale_order_line(osv.osv):
|
||||||
"""Allows to delete sale order lines in draft,cancel states"""
|
"""Allows to delete sale order lines in draft,cancel states"""
|
||||||
for rec in self.browse(cr, uid, ids, context=context):
|
for rec in self.browse(cr, uid, ids, context=context):
|
||||||
if rec.state not in ['draft', 'cancel']:
|
if rec.state not in ['draft', 'cancel']:
|
||||||
raise osv.except_osv(_('Invalid action !'), _('Cannot delete a sale order line which is %s !')%(rec.state,))
|
raise osv.except_osv(_('Invalid action !'), _('Cannot delete a sale order line which is %s !') %(rec.state,))
|
||||||
return super(sale_order_line, self).unlink(cr, uid, ids, context=context)
|
return super(sale_order_line, self).unlink(cr, uid, ids, context=context)
|
||||||
|
|
||||||
sale_order_line()
|
sale_order_line()
|
||||||
|
|
||||||
|
|
||||||
class sale_config_picking_policy(osv.osv_memory):
|
class sale_config_picking_policy(osv.osv_memory):
|
||||||
_name = 'sale.config.picking_policy'
|
_name = 'sale.config.picking_policy'
|
||||||
_inherit = 'res.config'
|
_inherit = 'res.config'
|
||||||
|
|
|
@ -116,10 +116,8 @@ class stock_picking(osv.osv):
|
||||||
result = super(stock_picking, self).action_invoice_create(cursor, user,
|
result = super(stock_picking, self).action_invoice_create(cursor, user,
|
||||||
ids, journal_id=journal_id, group=group, type=type,
|
ids, journal_id=journal_id, group=group, type=type,
|
||||||
context=context)
|
context=context)
|
||||||
|
|
||||||
picking_ids = result.keys()
|
picking_ids = result.keys()
|
||||||
invoice_ids = result.values()
|
invoice_ids = result.values()
|
||||||
|
|
||||||
invoices = {}
|
invoices = {}
|
||||||
for invoice in invoice_obj.browse(cursor, user, invoice_ids,
|
for invoice in invoice_obj.browse(cursor, user, invoice_ids,
|
||||||
context=context):
|
context=context):
|
||||||
|
@ -127,20 +125,16 @@ class stock_picking(osv.osv):
|
||||||
|
|
||||||
for picking in picking_obj.browse(cursor, user, picking_ids,
|
for picking in picking_obj.browse(cursor, user, picking_ids,
|
||||||
context=context):
|
context=context):
|
||||||
|
|
||||||
if not picking.sale_id:
|
if not picking.sale_id:
|
||||||
continue
|
continue
|
||||||
sale_lines = picking.sale_id.order_line
|
sale_lines = picking.sale_id.order_line
|
||||||
invoice_created = invoices[result[picking.id]]
|
invoice_created = invoices[result[picking.id]]
|
||||||
|
|
||||||
for inv in invoice_obj.browse(cursor, user, [invoice_created.id], context=context):
|
for inv in invoice_obj.browse(cursor, user, [invoice_created.id], context=context):
|
||||||
if not inv.fiscal_position:
|
if not inv.fiscal_position:
|
||||||
invoice_obj.write(cursor, user, [inv.id], {'fiscal_position': picking.sale_id.fiscal_position.id}, context=context)
|
invoice_obj.write(cursor, user, [inv.id], {'fiscal_position': picking.sale_id.fiscal_position.id}, context=context)
|
||||||
|
|
||||||
if picking.sale_id.client_order_ref:
|
if picking.sale_id.client_order_ref:
|
||||||
inv_name = picking.sale_id.client_order_ref + " : " + invoice_created.name
|
inv_name = picking.sale_id.client_order_ref + " : " + invoice_created.name
|
||||||
invoice_obj.write(cursor, user, [invoice_created.id], {'name': inv_name}, context=context)
|
invoice_obj.write(cursor, user, [invoice_created.id], {'name': inv_name}, context=context)
|
||||||
|
|
||||||
for sale_line in sale_lines:
|
for sale_line in sale_lines:
|
||||||
if sale_line.product_id.type == 'service' and sale_line.invoiced == False:
|
if sale_line.product_id.type == 'service' and sale_line.invoiced == False:
|
||||||
if group:
|
if group:
|
||||||
|
@ -182,10 +176,9 @@ class stock_picking(osv.osv):
|
||||||
'account_analytic_id': account_analytic_id,
|
'account_analytic_id': account_analytic_id,
|
||||||
'notes':sale_line.notes
|
'notes':sale_line.notes
|
||||||
}, context=context)
|
}, context=context)
|
||||||
self.pool.get('sale.order.line').write(cursor, user, [sale_line.id], {'invoiced':True,
|
self.pool.get('sale.order.line').write(cursor, user, [sale_line.id], {'invoiced': True,
|
||||||
'invoice_lines': [(6, 0, [invoice_line_id])],
|
'invoice_lines': [(6, 0, [invoice_line_id])],
|
||||||
})
|
})
|
||||||
|
|
||||||
return result
|
return result
|
||||||
|
|
||||||
def action_cancel(self, cr, uid, ids, context={}):
|
def action_cancel(self, cr, uid, ids, context={}):
|
||||||
|
@ -194,7 +187,7 @@ class stock_picking(osv.osv):
|
||||||
call_ship_end = True
|
call_ship_end = True
|
||||||
if pick.sale_id:
|
if pick.sale_id:
|
||||||
for picks in pick.sale_id.picking_ids:
|
for picks in pick.sale_id.picking_ids:
|
||||||
if picks.state not in ('done','cancel'):
|
if picks.state not in ('done', 'cancel'):
|
||||||
call_ship_end = False
|
call_ship_end = False
|
||||||
break
|
break
|
||||||
if call_ship_end:
|
if call_ship_end:
|
||||||
|
|
|
@ -68,7 +68,7 @@ class sale_order_line_make_invoice(osv.osv_memory):
|
||||||
'partner_id': order.partner_id.id,
|
'partner_id': order.partner_id.id,
|
||||||
'address_invoice_id': order.partner_invoice_id.id,
|
'address_invoice_id': order.partner_invoice_id.id,
|
||||||
'address_contact_id': order.partner_invoice_id.id,
|
'address_contact_id': order.partner_invoice_id.id,
|
||||||
'invoice_line': [(6,0,lines)],
|
'invoice_line': [(6, 0, lines)],
|
||||||
'currency_id' : order.pricelist_id.currency_id.id,
|
'currency_id' : order.pricelist_id.currency_id.id,
|
||||||
'comment': order.note,
|
'comment': order.note,
|
||||||
'payment_term': pay_term,
|
'payment_term': pay_term,
|
||||||
|
@ -81,7 +81,7 @@ class sale_order_line_make_invoice(osv.osv_memory):
|
||||||
sales_order_obj = self.pool.get('sale.order')
|
sales_order_obj = self.pool.get('sale.order')
|
||||||
wf_service = netsvc.LocalService('workflow')
|
wf_service = netsvc.LocalService('workflow')
|
||||||
for line in sales_order_line_obj.browse(cr, uid, context['active_ids']):
|
for line in sales_order_line_obj.browse(cr, uid, context['active_ids']):
|
||||||
if (not line.invoiced) and (line.state not in ('draft','cancel')):
|
if (not line.invoiced) and (line.state not in ('draft', 'cancel')):
|
||||||
if not line.order_id.id in invoices:
|
if not line.order_id.id in invoices:
|
||||||
invoices[line.order_id.id] = []
|
invoices[line.order_id.id] = []
|
||||||
line_id = sales_order_line_obj.invoice_line_create(cr, uid,
|
line_id = sales_order_line_obj.invoice_line_create(cr, uid,
|
||||||
|
@ -105,7 +105,7 @@ class sale_order_line_make_invoice(osv.osv_memory):
|
||||||
break
|
break
|
||||||
if flag:
|
if flag:
|
||||||
wf_service.trg_validate(uid, 'sale.order', line.order_id.id, 'all_lines', cr)
|
wf_service.trg_validate(uid, 'sale.order', line.order_id.id, 'all_lines', cr)
|
||||||
sales_order_obj.write(cr, uid, [line.order_id.id], {'state' : 'progress'})
|
sales_order_obj.write(cr, uid, [line.order_id.id], {'state': 'progress'})
|
||||||
|
|
||||||
if not invoices:
|
if not invoices:
|
||||||
raise osv.except_osv(_('Warning'), _('Invoice cannot be created for this Sale Order Line due to one of the following reasons:\n1.The state of this sale order line is either "draft" or "cancel"!\n2.The Sale Order Line is Invoiced!'))
|
raise osv.except_osv(_('Warning'), _('Invoice cannot be created for this Sale Order Line due to one of the following reasons:\n1.The state of this sale order line is either "draft" or "cancel"!\n2.The Sale Order Line is Invoiced!'))
|
||||||
|
|
|
@ -27,7 +27,7 @@ class sale_make_invoice(osv.osv_memory):
|
||||||
_description = "Sale Make Invoice"
|
_description = "Sale Make Invoice"
|
||||||
_columns = {
|
_columns = {
|
||||||
'grouped': fields.boolean('Group the invoices', help='Check the box to group the invoices for the same customers'),
|
'grouped': fields.boolean('Group the invoices', help='Check the box to group the invoices for the same customers'),
|
||||||
'invoice_date':fields.date('Invoice Date'),
|
'invoice_date': fields.date('Invoice Date'),
|
||||||
}
|
}
|
||||||
_defaults = {
|
_defaults = {
|
||||||
'grouped': False
|
'grouped': False
|
||||||
|
@ -66,7 +66,7 @@ class sale_make_invoice(osv.osv_memory):
|
||||||
'view_mode': 'tree,form',
|
'view_mode': 'tree,form',
|
||||||
'res_model': 'account.invoice',
|
'res_model': 'account.invoice',
|
||||||
'view_id': False,
|
'view_id': False,
|
||||||
'context': "{'type':'out_refund'}",
|
'context': "{'type': 'out_refund'}",
|
||||||
'type': 'ir.actions.act_window',
|
'type': 'ir.actions.act_window',
|
||||||
'search_view_id': id['res_id']
|
'search_view_id': id['res_id']
|
||||||
}
|
}
|
||||||
|
|
|
@ -83,12 +83,12 @@ class sale_advance_payment_inv(osv.osv_memory):
|
||||||
'reference': False,
|
'reference': False,
|
||||||
'account_id': sale.partner_id.property_account_receivable.id,
|
'account_id': sale.partner_id.property_account_receivable.id,
|
||||||
'partner_id': sale.partner_id.id,
|
'partner_id': sale.partner_id.id,
|
||||||
'address_invoice_id':sale.partner_invoice_id.id,
|
'address_invoice_id': sale.partner_invoice_id.id,
|
||||||
'address_contact_id':sale.partner_order_id.id,
|
'address_contact_id': sale.partner_order_id.id,
|
||||||
'invoice_line': [(6, 0, create_ids)],
|
'invoice_line': [(6, 0, create_ids)],
|
||||||
'currency_id' :sale.pricelist_id.currency_id.id,
|
'currency_id': sale.pricelist_id.currency_id.id,
|
||||||
'comment': '',
|
'comment': '',
|
||||||
'payment_term':sale.payment_term.id,
|
'payment_term': sale.payment_term.id,
|
||||||
'fiscal_position': sale.fiscal_position.id or sale.partner_id.property_account_position.id
|
'fiscal_position': sale.fiscal_position.id or sale.partner_id.property_account_position.id
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -98,7 +98,7 @@ class sale_advance_payment_inv(osv.osv_memory):
|
||||||
for inv in sale.invoice_ids:
|
for inv in sale.invoice_ids:
|
||||||
ids_inv.append(inv.id)
|
ids_inv.append(inv.id)
|
||||||
ids_inv.append(inv_id)
|
ids_inv.append(inv_id)
|
||||||
obj_sale.write(cr, uid, sale.id, {'invoice_ids':[(6, 0, ids_inv)]})
|
obj_sale.write(cr, uid, sale.id, {'invoice_ids': [(6, 0, ids_inv)]})
|
||||||
list_inv.append(inv_id)
|
list_inv.append(inv_id)
|
||||||
#
|
#
|
||||||
# If invoice on picking: add the cost on the SO
|
# If invoice on picking: add the cost on the SO
|
||||||
|
@ -127,7 +127,7 @@ class sale_advance_payment_inv(osv.osv_memory):
|
||||||
'res_model': 'sale.open.invoice',
|
'res_model': 'sale.open.invoice',
|
||||||
'type': 'ir.actions.act_window',
|
'type': 'ir.actions.act_window',
|
||||||
'target': 'new',
|
'target': 'new',
|
||||||
'context':context
|
'context': context
|
||||||
}
|
}
|
||||||
|
|
||||||
sale_advance_payment_inv()
|
sale_advance_payment_inv()
|
||||||
|
@ -164,7 +164,7 @@ class sale_open_invoice(osv.osv_memory):
|
||||||
'res_id': int(context['invoice_id'][0]),
|
'res_id': int(context['invoice_id'][0]),
|
||||||
'view_id': False,
|
'view_id': False,
|
||||||
'views': [(form_res, 'form'), (tree_res, 'tree')],
|
'views': [(form_res, 'form'), (tree_res, 'tree')],
|
||||||
'context': "{'type':'out_invoice'}",
|
'context': "{'type': 'out_invoice'}",
|
||||||
'type': 'ir.actions.act_window',
|
'type': 'ir.actions.act_window',
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue