本文整理汇总了Python中odoo.tests.common.Form.partner_id方法的典型用法代码示例。如果您正苦于以下问题:Python Form.partner_id方法的具体用法?Python Form.partner_id怎么用?Python Form.partner_id使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类odoo.tests.common.Form
的用法示例。
在下文中一共展示了Form.partner_id方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_state
# 需要导入模块: from odoo.tests.common import Form [as 别名]
# 或者: from odoo.tests.common.Form import partner_id [as 别名]
def test_state(self):
f = Form(self.env['account.invoice'])
f.partner_id = self.env.ref('base.res_partner_12')
with f.invoice_line_ids.new() as l:
l.product_id = self.env.ref('product.product_product_3')
invoice = f.save()
# I check that Initially customer invoice state is "Draft"
self.assertEqual(invoice.state, 'draft')
# I called the "Confirm Draft Invoices" wizard
w = Form(self.env['account.invoice.confirm']).save()
# I clicked on Confirm Invoices Button
w.with_context(
active_model='account.invoice',
active_id=invoice.id,
active_ids=invoice.ids,
type='out_invoice',
).invoice_confirm()
# I check that customer invoice state is "Open"
self.assertEqual(invoice.state, 'open')
# Electronic invoice must be present and have the same name as l10n_it_einvoice_name
self.assertEqual(invoice.l10n_it_einvoice_id.name, invoice.l10n_it_einvoice_name)
示例2: test_sale_mrp
# 需要导入模块: from odoo.tests.common import Form [as 别名]
# 或者: from odoo.tests.common.Form import partner_id [as 别名]
def test_sale_mrp(self):
warehouse0 = self.env.ref('stock.warehouse0')
# In order to test the sale_mrp module in OpenERP, I start by creating a new product 'Slider Mobile'
# I define product category Mobile Products Sellable.
with mute_logger('odoo.tests.common.onchange'):
# Suppress warning on "Changing your cost method" when creating a
# product category
pc = Form(self.env['product.category'])
pc.name = 'Mobile Products Sellable'
product_category_allproductssellable0 = pc.save()
uom_unit = self.env.ref('uom.product_uom_unit')
self.assertIn("seller_ids", self.env['product.template'].fields_get())
# I define product for Slider Mobile.
product = Form(self.env['product.template'])
product.categ_id = product_category_allproductssellable0
product.list_price = 200.0
product.name = 'Slider Mobile'
product.standard_price = 189.0
product.type = 'product'
product.uom_id = uom_unit
product.uom_po_id = uom_unit
product.route_ids.clear()
product.route_ids.add(warehouse0.manufacture_pull_id.route_id)
product.route_ids.add(warehouse0.mto_pull_id.route_id)
product_template_slidermobile0 = product.save()
product_component = Form(self.env['product.product'])
product_component.name = 'Battery'
product_product_bettery = product_component.save()
with Form(self.env['mrp.bom']) as bom:
bom.product_tmpl_id = product_template_slidermobile0
with bom.bom_line_ids.new() as line:
line.product_id = product_product_bettery
line.product_qty = 4
# I create a sale order for product Slider mobile
so_form = Form(self.env['sale.order'])
so_form.partner_id = self.env.ref('base.res_partner_4')
with so_form.order_line.new() as line:
line.product_id = product_template_slidermobile0.product_variant_ids
line.price_unit = 200
line.product_uom_qty = 500.0
line.customer_lead = 7.0
sale_order_so0 = so_form.save()
# I confirm the sale order
sale_order_so0.action_confirm()
# I verify that a manufacturing order has been generated, and that its name and reference are correct
mo = self.env['mrp.production'].search([('origin', 'like', sale_order_so0.name)], limit=1)
self.assertTrue(mo, 'Manufacturing order has not been generated')
示例3: test_state
# 需要导入模块: from odoo.tests.common import Form [as 别名]
# 或者: from odoo.tests.common.Form import partner_id [as 别名]
def test_state(self):
# In order to test Confirm Draft Invoice wizard I create an invoice
# and confirm it with this wizard
f = Form(self.env['account.invoice'])
f.partner_id = self.env.ref('base.res_partner_12')
with f.invoice_line_ids.new() as l:
l.product_id = self.env.ref('product.product_product_3')
invoice = f.save()
# I check that Initially customer invoice state is "Draft"
self.assertEqual(invoice.state, 'draft')
# I called the "Confirm Draft Invoices" wizard
w = Form(self.env['account.invoice.confirm']).save()
# I clicked on Confirm Invoices Button
w.with_context(
active_model='account.invoice',
active_id=invoice.id,
active_ids=invoice.ids,
type='out_invoice',
).invoice_confirm()
# I check that customer invoice state is "Open"
self.assertEqual(invoice.state, 'open')
# I check the journal associated and put this journal as not
moves = self.env['account.move.line'].search([
('invoice_id', '=', invoice.id)
])
self.assertGreater(len(moves), 0, 'You should have multiple moves')
moves[0].journal_id.write({'update_posted': True})
# I cancelled this open invoice using the button on invoice
invoice.action_invoice_cancel()
# I check that customer invoice is in the cancel state
self.assertEqual(invoice.state, 'cancel')
示例4: test_01_sale_mrp_kit_qty_delivered
# 需要导入模块: from odoo.tests.common import Form [as 别名]
# 或者: from odoo.tests.common.Form import partner_id [as 别名]
def test_01_sale_mrp_kit_qty_delivered(self):
""" Test that the quantities delivered are correct when
a kit with subkits is ordered with multiple backorders and returns
"""
# 'kit_parent' structure:
# ---------------------------
#
# kit_parent --|- kit_2 x2 --|- component_d x1
# | |- kit_1 x2 -------|- component_a x2
# | |- component_b x1
# | |- component_c x3
# |
# |- kit_3 x1 --|- component_f x1
# | |- component_g x2
# |
# |- component_e x1
# Creation of a sale order for x7 kit_parent
partner = self.env.ref('base.res_partner_1')
f = Form(self.env['purchase.order'])
f.partner_id = partner
with f.order_line.new() as line:
line.product_id = self.kit_parent
line.product_qty = 7.0
line.price_unit = 10
po = f.save()
po.button_confirm()
# Check picking creation, its move lines should concern
# only components. Also checks that the quantities are corresponding
# to the PO
self.assertEquals(len(po.picking_ids), 1)
order_line = po.order_line[0]
picking_original = po.picking_ids[0]
move_lines = picking_original.move_lines
products = move_lines.mapped('product_id')
kits = [self.kit_parent, self.kit_3, self.kit_2, self.kit_1]
components = [self.component_a, self.component_b, self.component_c, self.component_d, self.component_e,
self.component_f, self.component_g]
expected_quantities = {
self.component_a: 56.0,
self.component_b: 28.0,
self.component_c: 84.0,
self.component_d: 14.0,
self.component_e: 7.0,
self.component_f: 14.0,
self.component_g: 28.0
}
self.assertEquals(len(move_lines), 7)
self.assertTrue(not any(kit in products for kit in kits))
self.assertTrue(all(component in products for component in components))
self._assert_quantities(move_lines, expected_quantities)
# Process only 7 units of each component
qty_to_process = 7
move_lines.write({'quantity_done': qty_to_process})
# Create a backorder for the missing componenents
backorder_wizard = self.env['stock.backorder.confirmation'].create({'pick_ids': [(4, po.picking_ids[0].id)]})
backorder_wizard.process()
# Check that a backorded is created
self.assertEquals(len(po.picking_ids), 2)
backorder_1 = po.picking_ids - picking_original
self.assertEquals(backorder_1.backorder_id.id, picking_original.id)
# Even if some components are received completely,
# no KitParent should be received
self.assertEquals(order_line.qty_received, 0)
# Process just enough components to make 1 kit_parent
qty_to_process = {
self.component_a: 1,
self.component_c: 5,
}
self._process_quantities(backorder_1.move_lines, qty_to_process)
# Create a backorder for the missing componenents
backorder_wizard = self.env['stock.backorder.confirmation'].create({'pick_ids': [(4, backorder_1.id)]})
backorder_wizard.process()
# Only 1 kit_parent should be received at this point
self.assertEquals(order_line.qty_received, 1)
# Check that the second backorder is created
self.assertEquals(len(po.picking_ids), 3)
backorder_2 = po.picking_ids - picking_original - backorder_1
self.assertEquals(backorder_2.backorder_id.id, backorder_1.id)
# Set the components quantities that backorder_2 should have
expected_quantities = {
self.component_a: 48,
self.component_b: 21,
self.component_c: 72,
self.component_d: 7,
self.component_f: 7,
self.component_g: 21
#.........这里部分代码省略.........