[merge]
bzr revid: nicolas.vanhoren@openerp.com-20120105133525-ugp71actg373y5of
This commit is contained in:
@@ -51,8 +51,10 @@ This module provides :
|
||||
],
|
||||
'demo_xml': ['account_payment_demo.xml'],
|
||||
'test': [
|
||||
'test/account_payment.yml',
|
||||
'test/account_payment_report.yml'
|
||||
'test/account_payment_demo.yml',
|
||||
'test/cancel_payment_order.yml',
|
||||
'test/payment_order_process.yml',
|
||||
'test/account_payment_report.yml',
|
||||
],
|
||||
'installable': True,
|
||||
'active': False,
|
||||
|
||||
@@ -68,6 +68,7 @@ class payment_order(osv.osv):
|
||||
_rec_name = 'reference'
|
||||
_order = 'id desc'
|
||||
|
||||
#dead code
|
||||
def get_wizard(self, type):
|
||||
logger = netsvc.Logger()
|
||||
logger.notifyChannel("warning", netsvc.LOG_WARNING,
|
||||
@@ -235,6 +236,7 @@ class payment_line(osv.osv):
|
||||
break
|
||||
return result
|
||||
|
||||
#dead code
|
||||
def select_by_name(self, cr, uid, ids, name, args, context=None):
|
||||
if not ids: return {}
|
||||
partner_obj = self.pool.get('res.partner')
|
||||
|
||||
@@ -1,118 +0,0 @@
|
||||
-
|
||||
In order to test account_payment in OpenERP I created a new Bank Record
|
||||
-
|
||||
Creating a res.partner.bank record
|
||||
-
|
||||
!record {model: res.partner.bank, id: res_partner_bank_0}:
|
||||
acc_number: '126-2013269-08'
|
||||
partner_id: base.res_partner_9
|
||||
sequence: 0.0
|
||||
state: bank
|
||||
bank: base.res_bank_1
|
||||
-
|
||||
I created a new Payment Mode
|
||||
-
|
||||
Creating a payment.mode record
|
||||
-
|
||||
!record {model: payment.mode, id: payment_mode_m0}:
|
||||
bank_id: res_partner_bank_0
|
||||
journal: account.bank_journal
|
||||
name: TestMode
|
||||
|
||||
-
|
||||
I created a Supplier Invoice
|
||||
-
|
||||
Creating a account.invoice record
|
||||
-
|
||||
!record {model: account.invoice, id: account_invoice_payment}:
|
||||
account_id: account.a_pay
|
||||
address_contact_id: base.res_partner_address_tang
|
||||
address_invoice_id: base.res_partner_address_tang
|
||||
check_total: 300.0
|
||||
company_id: base.main_company
|
||||
currency_id: base.EUR
|
||||
invoice_line:
|
||||
- account_id: account.a_expense
|
||||
name: '[PC1] Basic PC'
|
||||
price_unit: 300.0
|
||||
product_id: product.product_product_pc1
|
||||
quantity: 1.0
|
||||
uos_id: product.product_uom_unit
|
||||
journal_id: account.expenses_journal
|
||||
partner_id: base.res_partner_asus
|
||||
reference_type: none
|
||||
type: in_invoice
|
||||
|
||||
-
|
||||
I make the supplier invoice in Open state
|
||||
-
|
||||
Performing a workflow action invoice_open on module account.invoice
|
||||
-
|
||||
!workflow {model: account.invoice, action: invoice_open, ref: account_invoice_payment}
|
||||
|
||||
-
|
||||
I create a new payment order
|
||||
-
|
||||
Creating a payment.order record
|
||||
-
|
||||
!record {model: payment.order, id: payment_order_0}:
|
||||
date_prefered: due
|
||||
mode: payment_mode_m0
|
||||
reference: !eval "'%s/006' %(datetime.now().year)"
|
||||
user_id: base.user_root
|
||||
|
||||
|
||||
-
|
||||
Creating a payment.order.create record
|
||||
-
|
||||
!record {model: payment.order.create, id: payment_order_create_0}:
|
||||
duedate: !eval time.strftime('%Y-%m-%d')
|
||||
|
||||
-
|
||||
I searched the entries using "Payment Create Order" wizard
|
||||
-
|
||||
Performing an osv_memory action search_entries on module payment.order.create
|
||||
-
|
||||
!python {model: payment.order.create}: |
|
||||
self.search_entries(cr, uid, [ref("payment_order_create_0")], {"lang": "en_US",
|
||||
"active_model": "payment.order", "active_ids": [ref("payment_order_0")],
|
||||
"tz": False, "active_id": ref("payment_order_0"), })
|
||||
-
|
||||
I check that Initially Payment order is in "draft" state
|
||||
-
|
||||
!assert {model: payment.order, id: payment_order_0}:
|
||||
- state == 'draft'
|
||||
-
|
||||
I pressed the confirm payment button to confirm the payment
|
||||
-
|
||||
Performing a workflow action open on module payment.order
|
||||
-
|
||||
!workflow {model: payment.order, action: open, ref: payment_order_0}
|
||||
-
|
||||
I check that Payment order is in "Confirmed" state
|
||||
-
|
||||
!assert {model: payment.order, id: payment_order_0}:
|
||||
- state == 'open'
|
||||
-
|
||||
I paid the payment using "Make Payments" Button
|
||||
-
|
||||
Creating a account.payment.make.payment record
|
||||
-
|
||||
!record {model: account.payment.make.payment, id: account_payment_make_payment_0}:
|
||||
{}
|
||||
|
||||
-
|
||||
Performing an osv_memory action launch_wizard on module account.payment.make.payment
|
||||
-
|
||||
!python {model: account.payment.make.payment}: |
|
||||
self.launch_wizard(cr, uid, [ref("account_payment_make_payment_0")], {"lang":
|
||||
"en_US", "active_model": "payment.order", "active_ids": [ref("payment_order_0")], "tz":
|
||||
False, "active_id": ref("payment_order_0"), })
|
||||
|
||||
-
|
||||
I check that Payment order is in "Done" state
|
||||
-
|
||||
!assert {model: payment.order, id: payment_order_0}:
|
||||
- state == 'done'
|
||||
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
-
|
||||
!record {model: payment.mode, id: payment_mode_1}:
|
||||
company_id: base.main_company
|
||||
-
|
||||
!record {model: payment.order, id: payment_order_2}:
|
||||
mode: payment_mode_1
|
||||
-
|
||||
!record {model: payment.line, id: payment_line_0}:
|
||||
name: Test
|
||||
communication: Test
|
||||
partner_id: base.res_partner_agrolait
|
||||
order_id: payment_order_2
|
||||
amount_currency: 100.00
|
||||
@@ -1,8 +1,8 @@
|
||||
-
|
||||
In order to test the PDF reports defined on Account Payment, Print a Payment Order
|
||||
-
|
||||
In order to test the PDF reports defined on Account Payment, I print a Payment Order report.
|
||||
-
|
||||
!python {model: payment.order}: |
|
||||
import netsvc, tools, os
|
||||
(data, format) = netsvc.LocalService('report.payment.order').create(cr, uid, [ref('account_payment.payment_order_1')], {}, {})
|
||||
(data, format) = netsvc.LocalService('report.payment.order').create(cr, uid, [ref('payment_order_1')], {}, {})
|
||||
if tools.config['test_report_directory']:
|
||||
file(os.path.join(tools.config['test_report_directory'], 'account_payment-payment_order_report.'+format), 'wb+').write(data)
|
||||
file(os.path.join(tools.config['test_report_directory'], 'account_payment-payment_order_report.'+format), 'wb+').write(data)
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
-
|
||||
In order to test the process of cancelling the payment order,
|
||||
-
|
||||
I confirm payment order.
|
||||
-
|
||||
!workflow {model: payment.order, action: open, ref: payment_order_1}
|
||||
-
|
||||
I check that payment order is now "Confirmed".
|
||||
-
|
||||
!assert {model: payment.order, id: payment_order_1, severity: error, string: Payment Order should be 'Confirmed'.}:
|
||||
- state == 'open'
|
||||
-
|
||||
Now, I cancel the payment order.
|
||||
-
|
||||
!workflow {model: payment.order, action: cancel, ref: payment_order_1}
|
||||
-
|
||||
I check that payment order is now "Cancelled".
|
||||
-
|
||||
!assert {model: payment.order, id: payment_order_1, severity: error, string: Payment Order should be 'Cancelled'.}:
|
||||
- state == 'cancel'
|
||||
-
|
||||
I again set the payment order to draft.
|
||||
-
|
||||
!python {model: payment.order}: |
|
||||
self.set_to_draft(cr, uid, [ref("payment_order_1")])
|
||||
-
|
||||
I check that payment order is now "Draft".
|
||||
-
|
||||
!assert {model: payment.order, id: payment_order_1, severity: error, string: Payment Order should be in 'Draft' state.}:
|
||||
- state == 'draft'
|
||||
@@ -0,0 +1,107 @@
|
||||
-
|
||||
In order to test the process of payment order, I start with the supplier invoice.
|
||||
-
|
||||
!python {model: account.invoice}: |
|
||||
self.write(cr, uid, [ref('account.demo_invoice_0')], {'check_total': 14})
|
||||
-
|
||||
In order to test account move line of journal, I check that there is no move attached to the invoice.
|
||||
-
|
||||
!python {model: account.invoice}: |
|
||||
invoice = self.browse(cr, uid, ref("account.demo_invoice_0"))
|
||||
assert (not invoice.move_id), "Moves are wrongly created for invoice."
|
||||
-
|
||||
I open the invoice.
|
||||
-
|
||||
!workflow {model: account.invoice, action: invoice_open, ref: account.demo_invoice_0}
|
||||
-
|
||||
I check that the invoice state is now "Open".
|
||||
-
|
||||
!assert {model: account.invoice, id: account.demo_invoice_0, severity: error, string: Invoice should be in 'Open' state}:
|
||||
- state == 'open'
|
||||
-
|
||||
I confirm the payment order.
|
||||
-
|
||||
!workflow {model: payment.order, action: open, ref: payment_order_1}
|
||||
-
|
||||
I check that payment order is now "Confirmed".
|
||||
-
|
||||
!assert {model: payment.order, id: payment_order_1, severity: error, string: Payment Order should be 'Confirmed'.}:
|
||||
- state == 'open'
|
||||
-
|
||||
!record {model: payment.order.create, id: payment_order_create_0}:
|
||||
duedate: !eval time.strftime('%Y-%m-%d')
|
||||
-
|
||||
I search for the invoice entries to make the payment.
|
||||
-
|
||||
!python {model: payment.order.create}: |
|
||||
self.search_entries(cr, uid, [ref("payment_order_create_0")], {
|
||||
"active_model": "payment.order", "active_ids": [ref("payment_order_1")],
|
||||
"active_id": ref("payment_order_1"), })
|
||||
-
|
||||
I create payment lines entries.
|
||||
-
|
||||
!python {model: payment.order.create}: |
|
||||
invoice = self.pool.get('account.invoice').browse(cr, uid, ref("account.demo_invoice_0"))
|
||||
move_line = invoice.move_id.line_id[0]
|
||||
self.write(cr, uid, [ref("payment_order_create_0")], {'entries': [(6,0,[move_line.id])]})
|
||||
self.create_payment(cr, uid, [ref("payment_order_create_0")], {
|
||||
"active_model": "payment.order", "active_ids": [ref("payment_order_1")],
|
||||
"active_id": ref("payment_order_1")})
|
||||
-
|
||||
I check that payment line is created with proper data.
|
||||
-
|
||||
!python {model: payment.order}: |
|
||||
invoice = self.pool.get('account.invoice').browse(cr, uid, ref("account.demo_invoice_0"))
|
||||
payment = self.browse(cr, uid, ref("payment_order_1"))
|
||||
payment_line = payment.line_ids[0]
|
||||
|
||||
assert payment_line.move_line_id, "move line is not created in payment line."
|
||||
assert invoice.move_id.name == payment_line.ml_inv_ref.number, "invoice reference number is not same created."
|
||||
assert invoice.partner_id == payment_line.partner_id, "Partner is not correct."
|
||||
assert invoice.date_due == payment_line.ml_maturity_date, "Due date is not correct."
|
||||
assert invoice.amount_total == payment_line.amount, "Payment amount is not correct."
|
||||
-
|
||||
After making all payments, I finish the payment order.
|
||||
-
|
||||
!python {model: payment.order}: |
|
||||
self.set_done(cr, uid, [ref("payment_order_1")])
|
||||
-
|
||||
I check that payment order is now "Done".
|
||||
-
|
||||
!assert {model: payment.order, id: payment_order_1, severity: error, string: Payment Order should be in 'Done' state}:
|
||||
- state == 'done'
|
||||
-
|
||||
I check that payment order is done with proper data.
|
||||
-
|
||||
!python {model: payment.order}: |
|
||||
payment = self.browse(cr, uid, ref("payment_order_1"))
|
||||
assert payment.date_done, "Date is not created."
|
||||
-
|
||||
I create a bank statement.
|
||||
-
|
||||
!record {model: account.bank.statement, id: account_bank_statement_1}:
|
||||
balance_end_real: 0.0
|
||||
balance_start: 0.0
|
||||
date: !eval time.strftime('%Y-%m-%d')
|
||||
journal_id: account.bank_journal
|
||||
name: /
|
||||
period_id: account.period_10
|
||||
-
|
||||
I import payment order lines for the bank statement.
|
||||
-
|
||||
!python {model: account.payment.populate.statement}: |
|
||||
payment = self.pool.get('payment.order').browse(cr, uid, ref("payment_order_1"))
|
||||
payment_line = payment.line_ids[0]
|
||||
import_payment_id = self.create(cr, uid, {'lines': [(6,0,[payment_line.id])]})
|
||||
self.populate_statement(cr, uid, [import_payment_id], {"statement_id": ref("account_bank_statement_1"),
|
||||
"active_model": "account.bank.statement", "journal_type": "cash",
|
||||
"active_id": ref("account_bank_statement_1")})
|
||||
-
|
||||
I am checking whether the calculations of Owner Account and Destination Account are done correctly or not in payment line.
|
||||
-
|
||||
!python {model: payment.line}: |
|
||||
payment = self.pool.get('payment.order').browse(cr, uid, ref("payment_order_1"))
|
||||
line_id = self.browse(cr, uid,payment.line_ids[0].id,context)
|
||||
assert line_id.info_owner, "Owner Account not proper."
|
||||
assert line_id.info_partner, "Destination Account not proper."
|
||||
assert line_id.ml_inv_ref, "Invoice reference is not proper."
|
||||
@@ -27,7 +27,8 @@
|
||||
<field name="arch" type="xml">
|
||||
<form string="Search Payment lines">
|
||||
<group col="4" colspan="6">
|
||||
<field name="entries"/>
|
||||
<separator colspan="4" string="Entries"/>
|
||||
<field name="entries" nolabel="1"/>
|
||||
</group>
|
||||
<separator colspan="4"/>
|
||||
<group col="2" colspan="4">
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
|
||||
from osv import osv
|
||||
|
||||
#TODO:REMOVE this wizard is not used
|
||||
class account_payment_make_payment(osv.osv_memory):
|
||||
_name = "account.payment.make.payment"
|
||||
_description = "Account make payment"
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<openerp>
|
||||
<data>
|
||||
|
||||
<!-- TODO:REMOVE this wizard is not used -->
|
||||
<record id="account_payment_make_payment_view" model="ir.ui.view">
|
||||
<field name="name">account.payment.make.payment.form</field>
|
||||
<field name="model">account.payment.make.payment</field>
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
<record model="workflow.activity" id="act_paid">
|
||||
<field name="wkf_id" ref="wkf_pos"/>
|
||||
<field name="name">paid</field>
|
||||
<field name="kind">dummy</field>
|
||||
<field name="kind">write({'state':'paid'})</field>
|
||||
</record>
|
||||
|
||||
<record model="workflow.activity" id="act_done">
|
||||
|
||||
@@ -61,10 +61,10 @@ Print product labels with barcode.
|
||||
'partner_view.xml',
|
||||
'process/product_process.xml'
|
||||
],
|
||||
'test':[
|
||||
'test/product_test.yml',
|
||||
'test/product_price_list.yml',
|
||||
'test/product_report.yml',
|
||||
'test': [
|
||||
'product_pricelist_demo.yml',
|
||||
'test/product_uom.yml',
|
||||
'test/product_pricelist.yml',
|
||||
],
|
||||
'installable': True,
|
||||
'active': False,
|
||||
|
||||
@@ -271,7 +271,7 @@ class product_pricelist(osv.osv):
|
||||
if price is not False:
|
||||
price_limit = price
|
||||
price = price * (1.0+(res['price_discount'] or 0.0))
|
||||
price = rounding(price, res['price_round'])
|
||||
price = rounding(price, res['price_round']) #TOFIX: rounding with tools.float_rouding
|
||||
price += (res['price_surcharge'] or 0.0)
|
||||
if res['price_min_margin']:
|
||||
price = max(price, price_limit+res['price_min_margin'])
|
||||
|
||||
@@ -218,6 +218,8 @@ class product_category(osv.osv):
|
||||
'child_id': fields.one2many('product.category', 'parent_id', string='Child Categories'),
|
||||
'sequence': fields.integer('Sequence', select=True, help="Gives the sequence order when displaying a list of product categories."),
|
||||
'type': fields.selection([('view','View'), ('normal','Normal')], 'Category Type'),
|
||||
'parent_left': fields.integer('Left Parent', select=1),
|
||||
'parent_right': fields.integer('Right Parent', select=1),
|
||||
}
|
||||
|
||||
|
||||
@@ -225,7 +227,11 @@ class product_category(osv.osv):
|
||||
'type' : lambda *a : 'normal',
|
||||
}
|
||||
|
||||
_order = "sequence, name"
|
||||
_parent_name = "parent_id"
|
||||
_parent_store = True
|
||||
_parent_order = 'sequence, name'
|
||||
_order = 'parent_left'
|
||||
|
||||
def _check_recursion(self, cr, uid, ids, context=None):
|
||||
level = 100
|
||||
while len(ids):
|
||||
@@ -406,10 +412,11 @@ class product_product(osv.osv):
|
||||
context = {}
|
||||
quantity = context.get('quantity') or 1.0
|
||||
pricelist = context.get('pricelist', False)
|
||||
partner = context.get('partner', False)
|
||||
if pricelist:
|
||||
for id in ids:
|
||||
try:
|
||||
price = self.pool.get('product.pricelist').price_get(cr,uid,[pricelist], id, quantity, context=context)[pricelist]
|
||||
price = self.pool.get('product.pricelist').price_get(cr,uid,[pricelist], id, quantity, partner=partner, context=context)[pricelist]
|
||||
except:
|
||||
price = 0.0
|
||||
res[id] = price
|
||||
|
||||
@@ -0,0 +1,62 @@
|
||||
-
|
||||
!record {model: product.product, id: product_product_pc2}:
|
||||
uom_id: product_uom_unit
|
||||
categ_id: product_category_pc
|
||||
-
|
||||
!record {model: product.pricelist, id: customer_pricelist}:
|
||||
name: Customer Pricelist
|
||||
type: sale
|
||||
version_id:
|
||||
- name: v1.0
|
||||
date_start: 2012-01-01
|
||||
items_id:
|
||||
- name: Default pricelist
|
||||
base: -1
|
||||
base_pricelist_id: list0
|
||||
- name: 10% Discount on PC2
|
||||
sequence: 1
|
||||
product_id: product_product_pc2
|
||||
base: !eval (ref('product.list_price'))
|
||||
price_discount: -0.10
|
||||
- name: 1 surchange on PC3
|
||||
sequence: 1
|
||||
product_id: product_product_pc3
|
||||
base: !eval (ref('product.list_price'))
|
||||
price_surcharge: 1
|
||||
- name: 5% Discount on all IT components
|
||||
sequence: 1
|
||||
min_quantity: 2
|
||||
base: !eval (ref('product.list_price'))
|
||||
categ_id: product_category_10
|
||||
price_discount: -0.05
|
||||
- name: v2.0 (Special Discount on all products during last 5 days in current year)
|
||||
date_start: 2011-12-27
|
||||
date_end: 2011-12-31
|
||||
items_id:
|
||||
- name: 30% Discount on all products
|
||||
price_discount: -0.30
|
||||
sequence: 1
|
||||
base: !eval (ref('product.list_price'))
|
||||
-
|
||||
!record {model: product.pricelist, id: supplier_pricelist}:
|
||||
name: Supplier Pricelist
|
||||
type: sale
|
||||
version_id:
|
||||
- name: v1.0
|
||||
items_id:
|
||||
- name: 20% Discount given by my supplier
|
||||
sequence: 1
|
||||
price_min_margin: 2
|
||||
price_max_margin: -5
|
||||
product_id: product_product_pc2
|
||||
base: -2
|
||||
-
|
||||
!record {model: pricelist.partnerinfo, id: supplier_pricelist0_product_pc2}:
|
||||
suppinfo_id: supplierinfo6
|
||||
min_quantity: 3
|
||||
price: 405
|
||||
-
|
||||
!record {model: pricelist.partnerinfo, id: supplier_pricelist1_product_pc2}:
|
||||
suppinfo_id: supplierinfo6
|
||||
min_quantity: 1
|
||||
price: 455
|
||||
@@ -1,124 +0,0 @@
|
||||
-
|
||||
In order to check the calculation of price of the products according to selected pricelist,
|
||||
I create a pricelist rule for giving discount on some quantities of product.
|
||||
-
|
||||
!record {model: product.pricelist.item, id: item0}:
|
||||
name: Default Public Pricelist for More Qty
|
||||
min_quantity: 15
|
||||
price_discount: -0.10
|
||||
-
|
||||
I check whether the product consumes the price, based on the given quantities, correctly or not.
|
||||
-
|
||||
!python {model: product.pricelist}: |
|
||||
product_obj = self.pool.get("product.product")
|
||||
result = self.price_get_multi(cr, uid, [ref("product.list0")], [(ref("product_product_pc1"),15,False)])
|
||||
new_price = result[ref("product_product_pc1")].values()
|
||||
context.update({'pricelist': ref("product.list0"), 'quantity': 15})
|
||||
product_price = product_obj.browse(cr, uid, ref("product_product_pc1"), context=context).price
|
||||
assert new_price[0] == product_price,"Discount is not given on price of the product."
|
||||
-
|
||||
I create a pricelist rule to give discount for a specific product.
|
||||
-
|
||||
!record {model: product.pricelist.item, id: pricelist_rules_for_pc2}:
|
||||
name: Default Public Pricelist for PC2
|
||||
min_quantity: 1
|
||||
product_id: product.product_product_pc2
|
||||
sequence: 4
|
||||
base: !eval (ref('product.list_price'))
|
||||
price_version_id: product.ver0
|
||||
price_discount: -0.20
|
||||
-
|
||||
I check whether the selected product is having the price correctly or not.
|
||||
-
|
||||
!python {model: product.pricelist}: |
|
||||
result = self.price_get_multi(cr, uid, [ref("product.list0")], [(ref("product_product_pc2"),1,False)])
|
||||
product_obj = self.pool.get("product.product")
|
||||
new_price = result[ref("product_product_pc2")].values()
|
||||
context.update({'pricelist': ref("product.list0"), 'quantity': 1})
|
||||
product_price = product_obj.browse(cr, uid, ref("product_product_pc2"), context=context).price
|
||||
assert new_price[0] == product_price,"Discount is not given on price of the special product."
|
||||
-
|
||||
I create a pricelist rule to give discount for a specific category of products.
|
||||
-
|
||||
!record {model: product.pricelist.item, id: pricelist_rules_category_1}:
|
||||
name: Default Public Pricelist for Category
|
||||
min_quantity: 1
|
||||
categ_id: product.cat1
|
||||
sequence: 3
|
||||
base: !eval (ref('product.list_price'))
|
||||
price_version_id: product.ver0
|
||||
price_discount: -0.25
|
||||
-
|
||||
I check whether the price of products of selected product category is correctly set or not.
|
||||
-
|
||||
!python {model: product.pricelist}: |
|
||||
result = self.price_get_multi(cr, uid, [ref("product.list0")], [(ref("product_product_fan2"),1,False)])
|
||||
product_obj = self.pool.get("product.product")
|
||||
new_price = result[ref("product_product_fan2")].values()
|
||||
context.update({'pricelist': ref("product.list0"), 'quantity': 1})
|
||||
product_price = product_obj.browse(cr, uid, ref("product_product_fan2"), context=context).price
|
||||
assert new_price[0] == product_price,"Discount is not given on price of the special category of products."
|
||||
-
|
||||
I create a pricelist to give the discount at the end of year.
|
||||
-
|
||||
!record {model: product.pricelist, id: product_price_list_end_year}:
|
||||
name: End of Year Price List
|
||||
type: sale
|
||||
version_id:
|
||||
- name: End of Year Price List Version
|
||||
items_id:
|
||||
- name: End of Year Price List Version Rule
|
||||
min_quantity: 1
|
||||
base: !eval (ref('product.list_price'))
|
||||
price_discount: -0.30
|
||||
-
|
||||
!record {model: product.pricelist.item, id: pricelist_rules_for_end_year1}:
|
||||
name: End of Year Price List Version Rule - Public Pricelist
|
||||
min_quantity: 1
|
||||
sequence: 2
|
||||
base: -1
|
||||
price_version_id: product.ver0
|
||||
base_pricelist_id: product_price_list_end_year
|
||||
-
|
||||
Now, I check that the end of the year pricelist rule is applied on products.
|
||||
-
|
||||
!python {model: product.pricelist}: |
|
||||
result = self.price_get_multi(cr, uid, [ref("product.list0")], [(ref("product_product_pc1"),1,False)])
|
||||
new_price = result[ref("product_product_pc1")].values()
|
||||
product_obj = self.pool.get("product.product")
|
||||
context.update({'pricelist': ref("product.list0"), 'quantity': 1})
|
||||
product_price = product_obj.browse(cr, uid, ref("product_product_pc1"), context=context).price
|
||||
assert new_price[0] == product_price,"Discount is not given on price of product at the end of the year."
|
||||
-
|
||||
I create a pricelist for special customers by which they can get discount on products.
|
||||
-
|
||||
!record {model: product.pricelist, id: special_customer_price_list1}:
|
||||
name: Price List For Special Customer
|
||||
type: sale
|
||||
version_id:
|
||||
- name: Special Customer Price List Version
|
||||
items_id:
|
||||
- name: Special Customer Price List Version Rule
|
||||
min_quantity: 1
|
||||
base: !eval (ref('product.list_price'))
|
||||
price_discount: -0.40
|
||||
-
|
||||
!record {model: res.partner, id: base.res_partner_agrolait}:
|
||||
property_product_pricelist: special_customer_price_list1
|
||||
-
|
||||
I check that the customer is getting the discount according to the pricelist.
|
||||
-
|
||||
!python {model: product.pricelist}: |
|
||||
result = self.price_get_multi(cr, uid, [ref("product.special_customer_price_list1")], [(ref("product_product_pc4"),1,ref("base.res_partner_agrolait"))])
|
||||
product_obj = self.pool.get("product.product")
|
||||
new_price = result[ref("product_product_pc4")].values()
|
||||
context.update({'pricelist': ref("product.special_customer_price_list1"), 'quantity': 1})
|
||||
product_price = product_obj.browse(cr, uid, ref("product_product_pc4"), context=context).price
|
||||
assert new_price[0] == product_price,"Discount is not given to special customer."
|
||||
-
|
||||
I set the supplier pricelist for a product to get the discount at the time of purchase.
|
||||
-
|
||||
!record {model: product.supplierinfo, id: supplierinfo5}:
|
||||
pricelist_ids:
|
||||
- min_quantity: 10
|
||||
price: 200
|
||||
@@ -0,0 +1,75 @@
|
||||
-
|
||||
In order to check the calculation of price of the products according to pricelist,
|
||||
-
|
||||
I check sale price of PC2.
|
||||
-
|
||||
!python {model: product.product}: |
|
||||
context.update({'pricelist': ref("customer_pricelist"), 'quantity':1})
|
||||
product = self.browse(cr, uid, ref("product_product_pc2"), context=context)
|
||||
assert product.price == product.lst_price-product.lst_price*(0.10), "Sell price is not correspond."
|
||||
-
|
||||
I check sale price of PC3.
|
||||
-
|
||||
!python {model: product.product}: |
|
||||
product = self.browse(cr, uid, ref("product_product_pc3"), context=context)
|
||||
assert product.price == product.lst_price + 1, "Sell price is not correspond."
|
||||
-
|
||||
I check sale price of IT componet.
|
||||
-
|
||||
!python {model: product.product}: |
|
||||
product = self.browse(cr, uid, ref("product_product_mb1"), context=context)
|
||||
assert product.price == product.lst_price, "Sell price is not correspond."
|
||||
|
||||
-
|
||||
I check sale price of IT componet if more than 3 PCE.
|
||||
-
|
||||
!python {model: product.product}: |
|
||||
context.update({'quantity':5})
|
||||
product = self.browse(cr, uid, ref("product_product_mb1"), context=context)
|
||||
assert product.price == product.lst_price-product.lst_price*(0.05), "Sell price is not correspond."
|
||||
-
|
||||
I check sale price of PC4.
|
||||
-
|
||||
!python {model: product.product}: |
|
||||
context.update({'quantity':1})
|
||||
product = self.browse(cr, uid, ref("product_product_pc4"), context=context)
|
||||
assert product.price == product.lst_price, "Sell price is not correspond."
|
||||
|
||||
-
|
||||
I check sale price of PC4 on end of year.
|
||||
-
|
||||
!python {model: product.product}: |
|
||||
context.update({'quantity':1, 'date': '2011-12-31'})
|
||||
product = self.browse(cr, uid, ref("product_product_pc4"), context=context)
|
||||
assert product.price == product.lst_price-product.lst_price*(0.30), "Sell price is not correspond."
|
||||
|
||||
-
|
||||
I check cost price of PC2.
|
||||
-
|
||||
!python {model: product.product}: |
|
||||
context.update({'quantity':1, 'date': False, 'partner': ref('base.res_partner_4'), 'pricelist': ref("supplier_pricelist")})
|
||||
product = self.browse(cr, uid, ref("product_product_pc2"), context=context)
|
||||
assert product.price == 450, "cost price is not correspond."
|
||||
-
|
||||
I check cost price of PC2 if more than 3 PCE.
|
||||
-
|
||||
!python {model: product.product}: |
|
||||
context.update({'quantity':3})
|
||||
product = self.browse(cr, uid, ref("product_product_pc2"), context=context)
|
||||
assert product.price == 400, "cost price is not correspond."
|
||||
|
||||
-
|
||||
I print the sale prices report.
|
||||
-
|
||||
!python {model: product.product}: |
|
||||
ctx = {'model': 'product.product', 'date': '2011-12-30', 'active_ids': [ref('product.product_product_pc1'), ref('product.product_product_pc2'), ref('product.product_product_pc3'), ref('product.product_product_pc4')]}
|
||||
data_dict = {
|
||||
'qty1': 1,
|
||||
'qty2': 5,
|
||||
'qty3': 10,
|
||||
'qty4': 15,
|
||||
'qty5': 30,
|
||||
'price_list':ref('customer_pricelist'),
|
||||
}
|
||||
from tools import test_reports
|
||||
test_reports.try_report_action(cr, uid, 'action_product_price_list',wiz_data=data_dict, context=ctx, our_module='product')
|
||||
@@ -1,16 +0,0 @@
|
||||
-
|
||||
Print the Products Pricelists Report through the wizard
|
||||
-
|
||||
!python {model: product.product}: |
|
||||
ctx={}
|
||||
ctx.update({'model': 'product.product','active_ids': [ref('product.product_product_pc1'), ref('product.product_product_pc3')]})
|
||||
data_dict = {'qty1': 1,
|
||||
'qty2': 5,
|
||||
'qty3': 10,
|
||||
'qty4': 0,
|
||||
'qty5': 0,
|
||||
'price_list':ref('product.list0')}
|
||||
from tools import test_reports
|
||||
test_reports.try_report_action(cr, uid, 'action_product_price_list',wiz_data=data_dict, context=ctx, our_module='product')
|
||||
|
||||
|
||||
@@ -1,33 +0,0 @@
|
||||
-
|
||||
In order to test product,I start by creating a 20KG UOM for 'Sugar'
|
||||
-
|
||||
!record {model: product.uom, id: product_20k_uom_sugar}:
|
||||
name: 20KG
|
||||
uom_type: bigger
|
||||
category_id: product.product_uom_categ_kgm
|
||||
factor_inv: 20
|
||||
-
|
||||
I create a 10KG UOM for 'Sugar'
|
||||
-
|
||||
!record {model: product.uom, id: product_10k_uom_sugar}:
|
||||
name: 10KG
|
||||
uom_type: bigger
|
||||
category_id: product.product_uom_categ_kgm
|
||||
factor_inv: 10
|
||||
-
|
||||
I create a new product 'Sugar' in 20KG UOM.
|
||||
-
|
||||
!record {model: product.product, id: product_sugar_id1}:
|
||||
categ_id: 'product.product_category_rawmaterial0'
|
||||
name: Sugar 20KG
|
||||
procure_method: make_to_order
|
||||
standard_price: 400.0
|
||||
uom_id: product.product_20k_uom_sugar
|
||||
uom_po_id: product.product_20k_uom_sugar
|
||||
-
|
||||
I test onchanged on UOM, Create Duplicate Product and Delete original Product.
|
||||
-
|
||||
!python {model: product.product}: |
|
||||
self.onchange_uom(cr ,uid, [ref("product_sugar_id1")], ref("product.product_20k_uom_sugar"), ref("product.product_10k_uom_sugar"))
|
||||
self.copy(cr, uid, ref("product_sugar_id1"))
|
||||
self.unlink(cr, uid, [ref("product_sugar_id1")])
|
||||
@@ -0,0 +1,15 @@
|
||||
-
|
||||
In order to test conversation of UOM,
|
||||
-
|
||||
I convert Grams into TON with price.
|
||||
-
|
||||
!python {model: product.uom}: |
|
||||
from_uom_id = ref("product_uom_gram")
|
||||
to_uom_id = ref("product_uom_ton")
|
||||
price = 2
|
||||
qty = 1020000
|
||||
price = self._compute_price(cr, uid, from_uom_id, price, to_uom_id)
|
||||
qty = self._compute_qty(cr, uid, from_uom_id, qty, to_uom_id)
|
||||
assert qty == 1.02, "Qty is not correspond."
|
||||
assert price == 2000000.0, "Price is not correspond."
|
||||
|
||||
Reference in New Issue
Block a user