},
multi='sums', help="The total amount."),
- 'invoice_quantity': fields.selection([('order', 'Ordered Quantities')], 'Invoice on', help="The sales order will automatically create the invoice proposition (draft invoice).", required=True, readonly=True, states={'draft': [('readonly', False)]}),
'payment_term': fields.many2one('account.payment.term', 'Payment Term'),
'fiscal_position': fields.many2one('account.fiscal.position', 'Fiscal Position'),
'company_id': fields.many2one('res.company', 'Company'),
'state': 'draft',
'user_id': lambda obj, cr, uid, context: uid,
'name': lambda obj, cr, uid, context: '/',
- 'invoice_quantity': 'order',
'partner_invoice_id': lambda self, cr, uid, context: context.get('partner_id', False) and self.pool.get('res.partner').address_get(cr, uid, [context['partner_id']], ['invoice'])['invoice'],
'partner_shipping_id': lambda self, cr, uid, context: context.get('partner_id', False) and self.pool.get('res.partner').address_get(cr, uid, [context['partner_id']], ['delivery'])['delivery'],
'note': lambda self, cr, uid, context: self.pool.get('res.users').browse(cr, uid, uid, context=context).company_id.sale_note
}
def _get_line_qty(self, cr, uid, line, context=None):
- if (line.order_id.invoice_quantity=='order'):
- if line.product_uos:
- return line.product_uos_qty or 0.0
+ if line.product_uos:
+ return line.product_uos_qty or 0.0
return line.product_uom_qty
def _get_line_uom(self, cr, uid, line, context=None):
- if (line.order_id.invoice_quantity=='order'):
- if line.product_uos:
- return line.product_uos.id
+ if line.product_uos:
+ return line.product_uos.id
return line.product_uom.id
def _prepare_order_line_invoice_line(self, cr, uid, line, account_id=False, context=None):
})
return super(sale_order, self).copy(cr, uid, id, default, context=context)
- #Might have been deleted before for a reason
- def shipping_policy_change(self, cr, uid, ids, policy, context=None):
- if not policy:
- return {}
- inv_qty = 'order'
- if policy == 'prepaid':
- inv_qty = 'order'
- elif policy == 'picking':
- inv_qty = 'procurement'
- return {'value': {'invoice_quantity': inv_qty}}
-
-
def _get_default_warehouse(self, cr, uid, context=None):
company_id = self.pool.get('res.users')._get_company(cr, uid, context=context)
warehouse_ids = self.pool.get('stock.warehouse').search(cr, uid, [('company_id', '=', company_id)], context=context)
def _get_picking_ids(self, cr, uid, ids, name, args, context=None):
res = {}
- for element in self.browse(cr, uid, ids, context=context):
- for procurement in element.procurement_group_id.procurement_ids:
+ for sale in self.browse(cr, uid, ids, context=context):
+ if not sale.procurement_group_id:
+ res[sale.id] = []
+ continue
+ for procurement in sale.procurement_group_id.procurement_ids:
if procurement.move_id and procurement.move_id.picking_id:
picking_ids.append(procurement.move_id.picking_id.id)
- res[element.id] = list(set(picking_ids))
+ res[sale.id] = list(set(picking_ids))
return res
def _prepare_order_line_procurement(self, cr, uid, order, line, group_id = False, context=None):
('prepaid', 'Before Delivery'),
], 'Create Invoice', required=True, readonly=True, states={'draft': [('readonly', False)], 'sent': [('readonly', False)]},
help="""On demand: A draft invoice can be created from the sales order when needed. \nOn delivery order: A draft invoice can be created from the delivery order when the products have been delivered. \nBefore delivery: A draft invoice is created from the sales order and must be paid before the products can be delivered."""),
- 'shipped': fields.function(_get_shipped, type='boolean', store={'stock.move': (_get_orders, ['state'], 10)}),
+ 'shipped': fields.function(_get_shipped, string='Delivered', type='boolean', store={'stock.move': (_get_orders, ['state'], 10)}),
'warehouse_id': fields.many2one('stock.warehouse', 'Warehouse', required=True),
'picking_ids': fields.function(_get_picking_ids, method=True, type='one2many', relation='stock.picking', string='Picking associated to this sale'),
}