[FIX] delivery: remove deprecated methods and field
Due to new Sale module
This commit is contained in:
@@ -77,70 +77,6 @@ class StockPicking(models.Model):
|
||||
self.send_to_shipper()
|
||||
return res
|
||||
|
||||
@api.multi
|
||||
def _prepare_shipping_invoice_line(self, invoice):
|
||||
self.ensure_one()
|
||||
invoice.ensure_one()
|
||||
|
||||
carrier = self.carrier_id
|
||||
|
||||
# No carrier
|
||||
if not carrier:
|
||||
return None
|
||||
# Carrier already invoiced on the sale order
|
||||
if any(inv_line.product_id.id == carrier.product_id.id for inv_line in invoice.invoice_line_ids):
|
||||
return None
|
||||
|
||||
# Classic carrier
|
||||
if carrier.delivery_type in ['fixed', 'base_on_rule']:
|
||||
carrier = carrier.verify_carrier(self.partner_id)
|
||||
if not carrier:
|
||||
raise UserError(_('The carrier %s (id: %d) has no delivery method!') % (self.carrier_id.name, self.carrier_id.id))
|
||||
quantity = sum([line.product_uom_qty for line in self.move_lines])
|
||||
price = carrier.get_price_from_picking(invoice.amount_untaxed, self.weight, self.volume, quantity)
|
||||
else:
|
||||
# Shipping provider
|
||||
price = self.carrier_price
|
||||
|
||||
if invoice.company_id.currency_id.id != invoice.currency_id.id:
|
||||
price = invoice.company_id.currency_id.with_context(date=invoice.date_invoice).compute(invoice.currency_id.id, price)
|
||||
account_id = carrier.product_id.property_account_income.id
|
||||
if not account_id:
|
||||
account_id = carrier.product_id.categ_id.property_account_income_categ.id
|
||||
|
||||
taxes = carrier.product_id.taxes_id
|
||||
taxes_ids = taxes.ids
|
||||
|
||||
# Apply original SO fiscal position
|
||||
if self.sale_id.fiscal_position_id:
|
||||
fpos = self.sale_id.fiscal_position_id
|
||||
account_id = fpos.map_account(account_id)
|
||||
taxes_ids = fpos.map_tax(taxes).ids
|
||||
|
||||
res = {
|
||||
'name': carrier.name,
|
||||
'invoice_id': invoice.id,
|
||||
'uom_id': carrier.product_id.uom_id.id,
|
||||
'product_id': carrier.product_id.id,
|
||||
'account_id': account_id,
|
||||
'price_unit': price,
|
||||
'quantity': 1,
|
||||
'invoice_line_tax_ids': [(6, 0, taxes_ids)],
|
||||
}
|
||||
|
||||
return res
|
||||
|
||||
@api.model
|
||||
def _invoice_create_line(self, moves, journal_id, inv_type='out_invoice'):
|
||||
InvoiceLine = self.env['account.invoice.line']
|
||||
invoice_ids = super(StockPicking, self)._invoice_create_line(moves, journal_id, inv_type=inv_type)
|
||||
for move in moves:
|
||||
for invoice in move.picking_id.sale_id.invoice_ids.filtered(lambda invoice: invoice.id in invoice_ids):
|
||||
invoice_line = move.picking_id._prepare_shipping_invoice_line(invoice)
|
||||
if invoice_line:
|
||||
InvoiceLine.create(invoice_line)
|
||||
return invoice_ids
|
||||
|
||||
@api.multi
|
||||
def send_to_shipper(self):
|
||||
self.ensure_one()
|
||||
|
||||
@@ -1,12 +1,5 @@
|
||||
<odoo>
|
||||
<template id="report_shipping2" inherit_id="stock.report_picking">
|
||||
<xpath expr="//div[@name='partner_header']" position="after">
|
||||
<div name="invoice_partner" t-if="o.picking_type_id.code == 'outgoing' and o.sale_id and o.sale_id.partner_invoice_id">
|
||||
Will be invoiced to:
|
||||
<div t-field="o.sale_id.partner_invoice_id"
|
||||
t-field-options='{"widget": "contact", "fields": ["address", "name", "phone", "fax"], "no_marker": true, "phone_icons": true}'/>
|
||||
</div>
|
||||
</xpath>
|
||||
<xpath expr="//th[@name='td_sched_date_h']" position="after">
|
||||
<th t-if="o.picking_type_id.code == 'outgoing'"><strong>Carrier</strong></th>
|
||||
<th><strong>Weight</strong></th>
|
||||
|
||||
Reference in New Issue
Block a user