[IMP] purchase: adaptation due to the new Sale module
Major changes: - No use of UoS anymore Reason: complete rewrite of the Sale module. Responsible: fp, dbo, nim
This commit is contained in:
@@ -589,7 +589,7 @@ class purchase_order(osv.osv):
|
||||
'price_unit': order_line.price_unit or 0.0,
|
||||
'quantity': order_line.product_qty,
|
||||
'product_id': order_line.product_id.id or False,
|
||||
'uos_id': order_line.product_uom.id or False,
|
||||
'uom_id': order_line.product_uom.id or False,
|
||||
'invoice_line_tax_ids': [(6, 0, [x.id for x in order_line.taxes_id])],
|
||||
'account_analytic_id': order_line.account_analytic_id.id or False,
|
||||
'purchase_line_id': order_line.id,
|
||||
@@ -754,7 +754,6 @@ class purchase_order(osv.osv):
|
||||
'name': name,
|
||||
'product_id': order_line.product_id.id,
|
||||
'product_uom': order_line.product_uom.id,
|
||||
'product_uos': order_line.product_uom.id,
|
||||
'date': order.date_order,
|
||||
'date_expected': order_line.date_planned,
|
||||
'location_id': order.partner_id.property_stock_supplier.id,
|
||||
@@ -772,7 +771,6 @@ class purchase_order(osv.osv):
|
||||
'origin': order.name,
|
||||
'route_ids': order.picking_type_id.warehouse_id and [(6, 0, [x.id for x in order.picking_type_id.warehouse_id.route_ids])] or [],
|
||||
'warehouse_id':order.picking_type_id.warehouse_id.id,
|
||||
'invoice_state': order.invoice_method == 'picking' and '2binvoiced' or 'none',
|
||||
}
|
||||
|
||||
diff_quantity = order_line.product_qty
|
||||
@@ -781,10 +779,8 @@ class purchase_order(osv.osv):
|
||||
tmp = move_template.copy()
|
||||
tmp.update({
|
||||
'product_uom_qty': min(procurement_qty, diff_quantity),
|
||||
'product_uos_qty': min(procurement_qty, diff_quantity),
|
||||
'move_dest_id': procurement.move_dest_id.id, #move destination is same as procurement destination
|
||||
'procurement_id': procurement.id,
|
||||
'invoice_state': procurement.rule_id.invoice_state or (procurement.location_id and procurement.location_id.usage == 'customer' and procurement.invoice_state=='2binvoiced' and '2binvoiced') or (order.invoice_method == 'picking' and '2binvoiced') or 'none', #dropship case takes from sale
|
||||
'propagate': procurement.rule_id.propagate,
|
||||
})
|
||||
diff_quantity -= min(procurement_qty, diff_quantity)
|
||||
@@ -793,7 +789,6 @@ class purchase_order(osv.osv):
|
||||
#split the future stock move in two because the route followed may be different.
|
||||
if float_compare(diff_quantity, 0.0, precision_rounding=order_line.product_uom.rounding) > 0:
|
||||
move_template['product_uom_qty'] = diff_quantity
|
||||
move_template['product_uos_qty'] = diff_quantity
|
||||
res.append(move_template)
|
||||
return res
|
||||
|
||||
@@ -1843,8 +1838,8 @@ class account_invoice_line(osv.Model):
|
||||
# calculate and write down the possible price difference between invoice price and product price
|
||||
for line in res:
|
||||
if line.get('invl_id', 0) == i_line.id and a == line['account_id']:
|
||||
uom = i_line.product_id.uos_id or i_line.product_id.uom_id
|
||||
valuation_price_unit = self.pool.get('product.uom')._compute_price(cr, uid, uom.id, i_line.product_id.standard_price, i_line.uos_id.id)
|
||||
uom = i_line.product_id.uom_id
|
||||
valuation_price_unit = self.pool.get('product.uom')._compute_price(cr, uid, uom.id, i_line.product_id.standard_price, i_line.uom_id.id)
|
||||
if i_line.product_id.cost_method != 'standard' and i_line.purchase_line_id:
|
||||
#for average/fifo/lifo costing method, fetch real cost price from incomming moves
|
||||
stock_move_obj = self.pool.get('stock.move')
|
||||
@@ -1868,7 +1863,7 @@ class account_invoice_line(osv.Model):
|
||||
'price': price_diff,
|
||||
'account_id': acc,
|
||||
'product_id': line['product_id'],
|
||||
'uos_id': line['uos_id'],
|
||||
'uom_id': line['uom_id'],
|
||||
'account_analytic_id': line['account_analytic_id'],
|
||||
'taxes': line.get('taxes', []),
|
||||
})
|
||||
@@ -1882,4 +1877,4 @@ class account_invoice_line(osv.Model):
|
||||
_columns = {
|
||||
'purchase_line_ids': fields.many2many('purchase.order.line', 'purchase_order_line_invoice_rel', 'invoice_id','order_line_id',
|
||||
'Purchase Order Lines', readonly=True, copy=False)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -207,8 +207,6 @@
|
||||
product_uom_qty: 1.0
|
||||
product_uom: product.product_uom_unit
|
||||
location_dest_id: stock.stock_location_customers
|
||||
invoice_state: 2binvoiced
|
||||
invoice_state: 2binvoiced
|
||||
move_type: direct
|
||||
picking_type_id: stock.picking_type_out
|
||||
-
|
||||
@@ -248,87 +246,3 @@
|
||||
# Due to credit field is removed
|
||||
# credit = self.browse(cr, uid, ref('account_anglo_stock_valuation')).credit
|
||||
# float_compare(credit, 9, precision_digits=2) == 0, "Stock valuation account is not credited successfully."
|
||||
-
|
||||
As the Invoice state of the picking order is To be invoiced. I create invoice for my outgoing picking order.
|
||||
-
|
||||
!python {model: stock.invoice.onshipping}: |
|
||||
wiz_id = self.create(cr, uid, {'journal_id': ref('sales_journal')},
|
||||
{'active_ids': [ref("stock_picking_out001")], "active_model": "stock.picking"})
|
||||
self.create_invoice(cr, uid, [wiz_id], {"active_ids": [ref("stock_picking_out001")], "active_id": ref("stock_picking_out001")})
|
||||
-
|
||||
I check that the customer invoice is created successfully.
|
||||
-
|
||||
!python {model: account.invoice}: |
|
||||
partner_id = self.pool.get('stock.picking').browse(cr, uid, ref('stock_picking_out001')).partner_id.id
|
||||
inv_ids = self.search(cr, uid, [('type','=','out_invoice'),('partner_id','=',partner_id)])
|
||||
assert inv_ids, 'No Invoice is generated!'
|
||||
-
|
||||
I open the Invoice.
|
||||
-
|
||||
!python {model: stock.picking}: |
|
||||
move_name = self.pool.get('stock.picking').browse(cr, uid, ref('stock_picking_out001')).name
|
||||
account_invoice = self.pool.get('account.invoice').search(cr, uid, [('origin', '=', move_name)])
|
||||
self.pool.get('account.invoice').signal_workflow(cr, uid, account_invoice, 'invoice_open')
|
||||
-
|
||||
I check Income Account is Credited sucessfully when Invoice validated.
|
||||
-
|
||||
!python {model: account.account}: |
|
||||
from openerp.tools import float_compare
|
||||
# Due to credit field is removed
|
||||
# credit = self.browse(cr, uid, ref('account_anglo_income')).credit
|
||||
# float_compare(credit, 20, precision_digits=2) == 0, "Income Account is not Credited successfully."
|
||||
-
|
||||
I check Cost of goods sold account for debit.
|
||||
-
|
||||
!python {model: account.account}: |
|
||||
from openerp.tools import float_compare
|
||||
# Due to debit field is removed
|
||||
# debit = self.browse(cr, uid, ref('account_anglo_cogs')).debit
|
||||
# float_compare(debit, 9, precision_digits=2) == 0, "Cost of goods sale is not Debited successfully."
|
||||
-
|
||||
I check Stock Interim account (Delivery)
|
||||
-
|
||||
!python {model: account.account}: |
|
||||
from openerp.tools import float_compare
|
||||
# Due to credit field is removed
|
||||
# credit = self.browse(cr, uid, ref('account_anglo_stock_output')).credit
|
||||
# float_compare(credit, 9, precision_digits=2) == 0, "Stock Interim account (Delivery) is not credited successfully."
|
||||
-
|
||||
I check Receivable(Debtor) Account for debit.
|
||||
-
|
||||
!python {model: account.account}: |
|
||||
from openerp.tools import float_compare
|
||||
# Due to debit field is removed
|
||||
# debit = self.browse(cr, uid, ref('account_anglo_receivable')).debit
|
||||
# float_compare(debit, 20, precision_digits=2) == 0, "Receivable(Debtors) Account is not Debited successfully."
|
||||
-
|
||||
I pay the invoice.
|
||||
-
|
||||
!python {model: account.invoice}: |
|
||||
move_name = self.pool.get('stock.picking').browse(cr, uid, ref('stock_picking_out001')).name
|
||||
account_invoice= self.pool.get('account.invoice').search(cr, uid, [('origin', '=', move_name)])
|
||||
journal_ids = self.pool.get('account.journal').search(cr, uid, [('type', '=', 'cash')], limit=1)
|
||||
import time
|
||||
for invoice_id in account_invoice:
|
||||
self.pool.get('account.invoice').pay_and_reconcile(cr, uid, [invoice_id], journal_ids[0], 20.0)
|
||||
-
|
||||
I check Receivable(Debtor) Account for credit.
|
||||
-
|
||||
!python {model: account.account}: |
|
||||
from openerp.tools import float_compare
|
||||
# Due to credit field is removed
|
||||
# credit = self.browse(cr, uid, ref('account_anglo_receivable')).credit
|
||||
# float_compare(credit, 20, precision_digits=2) == 0, "Receivable(Debtors) Account is not Credited successfully."
|
||||
-
|
||||
I check Bank/Cash account is debited sucessfully after invoice paid.
|
||||
-
|
||||
!python {model: account.account}: |
|
||||
from openerp.tools import float_compare
|
||||
# Due to debit field is removed
|
||||
# debit = self.browse(cr, uid, ref('account_anglo_cash')).debit
|
||||
# float_compare(debit, 20, precision_digits=2) == 0, "Bank/Cash account is not successfully credited."
|
||||
-
|
||||
I reset the company to not use anglo saxon accounting.
|
||||
-
|
||||
!python {model: res.company}: |
|
||||
self.pool.get('res.company').write(cr, uid, ref("base.main_company"), {'anglo_saxon_accounting': False,})
|
||||
|
||||
@@ -209,8 +209,6 @@
|
||||
product_id: product_fifo_anglo_saxon
|
||||
product_uom_qty: 1.0
|
||||
location_dest_id: stock.stock_location_customers
|
||||
invoice_state: 2binvoiced
|
||||
invoice_state: 2binvoiced
|
||||
move_type: direct
|
||||
picking_type_id: stock.picking_type_out
|
||||
-
|
||||
@@ -248,92 +246,3 @@
|
||||
# Due to credit field is removed
|
||||
# credit = self.browse(cr, uid, ref('account_anglo_stock_valuation_fifo')).credit
|
||||
# assert float_compare(credit, 9, precision_digits=2) == 0, "Stock valuation account is not credited successfully."
|
||||
-
|
||||
As the Invoice state of the picking order is To be invoiced. I create invoice for my outgoing picking order.
|
||||
-
|
||||
!python {model: stock.invoice.onshipping}: |
|
||||
wiz_id = self.create(cr, uid, {'journal_id': ref('sales_journal')},
|
||||
{'active_ids': [ref("stock_picking_out001_fifo")], "active_model": "stock.picking"})
|
||||
self.create_invoice(cr, uid, [wiz_id], {"lang": "en_US",
|
||||
"search_default_available": 1, "tz": False, "active_model": "stock.picking",
|
||||
"contact_display": "partner", "active_ids": [ref("stock_picking_out001_fifo")], "active_id": ref("stock_picking_out001_fifo")})
|
||||
-
|
||||
I check that the customer invoice is created successfully.
|
||||
-
|
||||
!python {model: account.invoice}: |
|
||||
partner_id = self.pool.get('stock.picking').browse(cr, uid, ref('stock_picking_out001_fifo')).partner_id.id
|
||||
inv_ids = self.search(cr, uid, [('type','=','out_invoice'),('partner_id','=',partner_id)])
|
||||
assert inv_ids, 'No Invoice is generated!'
|
||||
-
|
||||
I open the Invoice.
|
||||
-
|
||||
!python {model: stock.picking}: |
|
||||
move_name = self.pool.get('stock.picking').browse(cr, uid, ref('stock_picking_out001_fifo')).name
|
||||
account_invoice_id = self.pool.get('account.invoice').search(cr, uid, [('origin', '=', move_name)])[0]
|
||||
account_invoice = self.pool.get('account.invoice').browse(cr, uid, account_invoice_id)
|
||||
self.pool.get('account.invoice.line').write(cr, uid, account_invoice.invoice_line_ids.ids, {'invoice_line_tax_ids': [(6, 0, [])]})
|
||||
# remove once @depends works
|
||||
#self.pool.get('account.invoice').compute_taxes(cr, uid, account_invoice)
|
||||
self.pool.get('account.invoice').signal_workflow(cr, uid, [account_invoice.id], 'invoice_open')
|
||||
-
|
||||
I check Income Account is Credited sucessfully when Invoice validated.
|
||||
-
|
||||
!python {model: account.account}: |
|
||||
from openerp.tools import float_compare
|
||||
# Due to credit field is removed
|
||||
# credit = self.browse(cr, uid, ref('account_anglo_income_fifo')).credit
|
||||
# assert float_compare(credit, 20, precision_digits=2) == 0, "Income Account is not Credited successfully."
|
||||
-
|
||||
I check Cost of goods sold account for debit.
|
||||
-
|
||||
!python {model: account.account}: |
|
||||
from openerp.tools import float_compare
|
||||
# Due to credit field is removed
|
||||
# debit = self.browse(cr, uid, ref('account_anglo_cogs_fifo')).debit
|
||||
# assert float_compare(debit, 9, precision_digits=2) == 0, "Cost of goods sale is not Debited successfully."
|
||||
-
|
||||
I check Stock Interim account (Delivery)
|
||||
-
|
||||
!python {model: account.account}: |
|
||||
from openerp.tools import float_compare
|
||||
# Due to credit field is removed
|
||||
# credit = self.browse(cr, uid, ref('account_anglo_stock_output_fifo')).credit
|
||||
# assert float_compare(credit, 9, precision_digits=2) == 0, "Stock Interim account (Delivery) is not credited successfully."
|
||||
-
|
||||
I check Receivable(Debtor) Account for debit.
|
||||
-
|
||||
!python {model: account.account}: |
|
||||
from openerp.tools import float_compare
|
||||
# Due to debit field is removed
|
||||
# debit = self.browse(cr, uid, ref('account_anglo_receivable_fifo')).debit
|
||||
# assert float_compare(debit, 20, precision_digits=2) == 0, "Receivable(Debtors) Account is not Debited successfully."
|
||||
-
|
||||
I pay the invoice.
|
||||
-
|
||||
!python {model: account.invoice}: |
|
||||
move_name = self.pool.get('stock.picking').browse(cr, uid, ref('stock_picking_out001_fifo')).name
|
||||
account_invoice = self.pool.get('account.invoice').search(cr, uid, [('origin', '=', move_name)])
|
||||
journal_ids = self.pool.get('account.journal').search(cr, uid, [('type', '=', 'cash')], limit=1)
|
||||
import time
|
||||
pay = self.pay_and_reconcile(cr, uid, account_invoice, journal_ids[0], 20.0)
|
||||
-
|
||||
I check Receivable(Debtor) Account for credit.
|
||||
-
|
||||
!python {model: account.account}: |
|
||||
from openerp.tools import float_compare
|
||||
# Due to credit field is removed
|
||||
# credit = self.browse(cr, uid, ref('account_anglo_receivable_fifo')).credit
|
||||
# assert float_compare(credit, 20, precision_digits=2) == 0, "Receivable(Debtors) Account is not Credited successfully."
|
||||
-
|
||||
I check Bank/Cash account is debited sucessfully after invoice paid.
|
||||
-
|
||||
!python {model: account.account}: |
|
||||
from openerp.tools import float_compare
|
||||
# Due to debit field is removed
|
||||
# debit = self.browse(cr, uid, ref('account_anglo_cash_fifo')).debit
|
||||
# assert float_compare(debit, 20, precision_digits=2) == 0, "Bank/Cash account is not successfully credited."
|
||||
-
|
||||
I reset the company to not use anglo saxon accounting.
|
||||
-
|
||||
!python {model: res.company}: |
|
||||
self.pool.get('res.company').write(cr, uid, ref("base.main_company"), {'anglo_saxon_accounting': False,})
|
||||
|
||||
Reference in New Issue
Block a user