diff --git a/addons/account/tests/test_account_customer_invoice.py b/addons/account/tests/test_account_customer_invoice.py index 7799f70f13ced7..c69d7a6c5ba22c 100644 --- a/addons/account/tests/test_account_customer_invoice.py +++ b/addons/account/tests/test_account_customer_invoice.py @@ -18,9 +18,39 @@ def test_customer_invoice(self): # Test with that user which have rights to make Invoicing and payment and who is accountant. # Create a customer invoice self.account_invoice_obj = self.env['account.invoice'] - self.payment_term = self.env.ref('account.account_payment_term_advance') + account_payment_term_advance = self.env['account.payment.term'].create(dict( + name="30% Advance End of Following Month", + note="Payment terms: 30% Advance End of Following Month", + line_ids=[ + (5, 0), + (0, 0, {'value': 'percent', 'value_amount': 30.0, 'sequence': 400, 'days': 0, 'option': 'day_after_invoice_date'}), + (0, 0, {'value': 'balance', 'value_amount': 0.0, 'sequence': 500, 'days': 0, 'option': 'last_day_following_month'}) + ] + )) + self.payment_term = account_payment_term_advance self.journalrec = self.env['account.journal'].search([('type', '=', 'sale')])[0] - self.partner3 = self.env.ref('base.res_partner_3') + res_partner_category_8 = self.env['res.partner.category'].create(dict( + name="Consultancy Services", + color=5 + )) + res_partner_category_14 = self.env['res.partner.category'].create(dict( + name="Manufacturer", + color=10 + )) + res_partner_3 = self.env['res.partner'].create(dict( + name="China Export", + supplier=True, + category_id=[(6, 0, [res_partner_category_8.id, res_partner_category_14.id])], + is_company=True, + city="Shanghai", + zip="200000", + country_id=self.env.ref('base.cn').id, + street="52 Chop Suey street", + email="chinaexport@yourcompany.example.com", + phone="+86 21 6484 5671", + website="http://www.chinaexport.com/" + )) + self.partner3 = res_partner_3 account_user_type = self.env.ref('account.data_account_type_receivable') self.ova = self.env['account.account'].search([('user_type_id', '=', self.env.ref('account.data_account_type_current_assets').id)], limit=1) @@ -32,10 +62,26 @@ def test_customer_invoice(self): reconcile=True, )) + product_category_5 = self.env['product.category'].create(dict( + parent_id=self.env.ref('product.product_category_1').id, + name="Physical" + )) + product_product_5 = self.env['product.product'].create(dict( + name="Custom Computer (kit)", + categ_id=product_category_5.id, + standard_price=600.0, + list_price=147.0, + type="consu", + uom_id=self.env.ref('product.product_uom_unit').id, + uom_po_id=self.env.ref('product.product_uom_unit').id, + description="Custom computer shipped in kit.", + default_code="E-COM06" + )) + invoice_line_data = [ (0, 0, { - 'product_id': self.env.ref('product.product_product_5').id, + 'product_id': product_product_5.id, 'quantity': 10.0, 'account_id': self.env['account.account'].search([('user_type_id', '=', self.env.ref('account.data_account_type_revenue').id)], limit=1).id, 'name': 'product test 5', @@ -106,9 +152,39 @@ def test_customer_invoice_tax(self): self.env.user.company_id.tax_calculation_rounding_method = 'round_globally' - payment_term = self.env.ref('account.account_payment_term_advance') + account_payment_term_advance = self.env['account.payment.term'].create(dict( + name="30% Advance End of Following Month", + note="Payment terms: 30% Advance End of Following Month", + line_ids=[ + (5, 0), + (0, 0, {'value': 'percent', 'value_amount': 30.0, 'sequence': 400, 'days': 0, 'option': 'day_after_invoice_date'}), + (0, 0, {'value': 'balance', 'value_amount': 0.0, 'sequence': 500, 'days': 0, 'option': 'last_day_following_month'}) + ] + )) + payment_term = account_payment_term_advance journalrec = self.env['account.journal'].search([('type', '=', 'sale')])[0] - partner3 = self.env.ref('base.res_partner_3') + res_partner_category_8 = self.env['res.partner.category'].create(dict( + name="Consultancy Services", + color=5 + )) + res_partner_category_14 = self.env['res.partner.category'].create(dict( + name="Manufacturer", + color=10 + )) + res_partner_3 = self.env['res.partner'].create(dict( + name="China Export", + supplier=True, + category_id=[(6, 0, [res_partner_category_8.id, res_partner_category_14.id])], + is_company=True, + city="Shanghai", + zip="200000", + country_id=self.env.ref('base.cn').id, + street="52 Chop Suey street", + email="chinaexport@yourcompany.example.com", + phone="+86 21 6484 5671", + website="http://www.chinaexport.com/" + )) + partner3 = res_partner_3 account_id = self.env['account.account'].search([('user_type_id', '=', self.env.ref('account.data_account_type_revenue').id)], limit=1).id tax = self.env['account.tax'].create({ @@ -118,10 +194,53 @@ def test_customer_invoice_tax(self): 'type_tax_use': 'sale', }) + product_category_3 = self.env['product.category'].create(dict( + parent_id=self.env.ref('product.product_category_1').id, + name="Services" + )) + product_product_1 = self.env['product.product'].create(dict( + name="GAP Analysis Service", + categ_id=product_category_3.id, + standard_price=20.5, + list_price=30.75, + type="service", + uom_id=self.env.ref('product.product_uom_hour').id, + uom_po_id=self.env.ref('product.product_uom_hour').id, + description="Example of products to invoice based on delivery.", + invoice_policy="delivery" + )) + product_product_2 = self.env['product.product'].create(dict( + name="Support Service", + categ_id=product_category_3.id, + standard_price=25.5, + list_price=38.25, + type="service", + uom_id=self.env.ref('product.product_uom_hour').id, + uom_po_id=self.env.ref('product.product_uom_hour').id, + description="Example of product to invoice based on delivery.", + invoice_policy="delivery" + )) + product_category_5 = self.env['product.category'].create(dict( + parent_id=self.env.ref('product.product_category_1').id, + name="Physical" + )) + product_product_3 = self.env['product.product'].create(dict( + name="Computer SC234", + categ_id=product_category_5.id, + standard_price=450.0, + list_price=300.0, + type="consu", + uom_id=self.env.ref('product.product_uom_unit').id, + uom_po_id=self.env.ref('product.product_uom_unit').id, + description_sale="""17" LCD Monitor Processor AMD 8-Core""", + default_code="PCSC234", + invoice_policy="delivery" + )) + invoice_line_data = [ (0, 0, { - 'product_id': self.env.ref('product.product_product_1').id, + 'product_id': product_product_1.id, 'quantity': 40.0, 'account_id': account_id, 'name': 'product test 1', @@ -132,7 +251,7 @@ def test_customer_invoice_tax(self): ), (0, 0, { - 'product_id': self.env.ref('product.product_product_2').id, + 'product_id': product_product_2.id, 'quantity': 21.0, 'account_id': self.env['account.account'].search([('user_type_id', '=', self.env.ref('account.data_account_type_revenue').id)], limit=1).id, 'name': 'product test 2', @@ -143,7 +262,7 @@ def test_customer_invoice_tax(self): ), (0, 0, { - 'product_id': self.env.ref('product.product_product_3').id, + 'product_id': product_product_3.id, 'quantity': 21.0, 'account_id': self.env['account.account'].search([('user_type_id', '=', self.env.ref('account.data_account_type_revenue').id)], limit=1).id, 'name': 'product test 3', @@ -182,7 +301,28 @@ def test_customer_invoice_tax_refund(self): }) journalrec = self.env['account.journal'].search([('type', '=', 'sale')])[0] - partner3 = self.env.ref('base.res_partner_3') + res_partner_category_8 = self.env['res.partner.category'].create(dict( + name="Consultancy Services", + color=5 + )) + res_partner_category_14 = self.env['res.partner.category'].create(dict( + name="Manufacturer", + color=10 + )) + res_partner_3 = self.env['res.partner'].create(dict( + name="China Export", + supplier=True, + category_id=[(6, 0, [res_partner_category_8.id, res_partner_category_14.id])], + is_company=True, + city="Shanghai", + zip="200000", + country_id=self.env.ref('base.cn').id, + street="52 Chop Suey street", + email="chinaexport@yourcompany.example.com", + phone="+86 21 6484 5671", + website="http://www.chinaexport.com/" + )) + partner3 = res_partner_3 account_id = self.env['account.account'].search([('user_type_id', '=', self.env.ref('account.data_account_type_revenue').id)], limit=1).id tax = self.env['account.tax'].create({ @@ -194,10 +334,26 @@ def test_customer_invoice_tax_refund(self): 'refund_account_id': tax_refund_account.id }) + product_category_3 = self.env['product.category'].create(dict( + parent_id=self.env.ref('product.product_category_1').id, + name="Services" + )) + product_product_1 = self.env['product.product'].create(dict( + name="GAP Analysis Service", + categ_id=product_category_3.id, + standard_price=20.5, + list_price=30.75, + type="service", + uom_id=self.env.ref('product.product_uom_hour').id, + uom_po_id=self.env.ref('product.product_uom_hour').id, + description="Example of products to invoice based on delivery.", + invoice_policy="delivery" + )) + invoice_line_data = [ (0, 0, { - 'product_id': self.env.ref('product.product_product_1').id, + 'product_id': product_product_1.id, 'quantity': 40.0, 'account_id': account_id, 'name': 'product test 1', diff --git a/addons/account/tests/test_account_invoice_rounding.py b/addons/account/tests/test_account_invoice_rounding.py index 9b0ef0fc9e8851..d3a701e7112503 100644 --- a/addons/account/tests/test_account_invoice_rounding.py +++ b/addons/account/tests/test_account_invoice_rounding.py @@ -31,8 +31,34 @@ def create_cash_rounding(self, rounding, method, strategy): def create_invoice(self, amount, cash_rounding_id, tax_amount=None): """ Returns an open invoice """ + res_partner_category_0 = self.env['res.partner.category'].create(dict( + name="Partner", + color=1, + )) + res_partner_category_7 = self.env['res.partner.category'].create(dict( + name="IT Services", + color=5, + parent_id=res_partner_category_0.id + )) + res_partner_category_9 = self.env['res.partner.category'].create(dict( + name="Components Buyer", + color=6 + )) + res_partner_2 = self.env['res.partner'].create(dict( + name="Agrolait", + category_id=[(6, 0, [res_partner_category_7.id, res_partner_category_9.id])], + is_company=True, + city="Wavre", + zip="1300", + country_id=self.env.ref('base.be').id, + street="69 rue de Namur", + email="agrolait@yourcompany.example.com", + phone="+32 10 588 558", + website="http://www.agrolait.com", + property_payment_term_id=self.env.ref('account.account_payment_term_net').id + )) invoice_id = self.env['account.invoice'].create({ - 'partner_id': self.env.ref("base.res_partner_2").id, + 'partner_id': res_partner_2.id, 'reference_type': 'none', 'currency_id': self.env.ref('base.USD').id, 'name': 'invoice test rounding', @@ -42,8 +68,46 @@ def create_invoice(self, amount, cash_rounding_id, tax_amount=None): }) if tax_amount: self.fixed_tax.amount = tax_amount + + product_category_5 = self.env['product.category'].create(dict( + parent_id=self.env.ref("product.product_category_1").id, + name="Physical" + )) + + product_attribute_1 = self.env['product.attribute'].create(dict( + name="Memory" + )) + + product_attribute_2 = self.env['product.attribute'].create(dict( + name="Color" + )) + + product_attribute_value_1 = self.env['product.attribute.value'].create(dict( + name="16 GB", + attribute_id=product_attribute_1.id + )) + + product_attribute_value_3 = self.env['product.attribute.value'].create(dict( + name="White", + attribute_id=product_attribute_2.id + )) + + # self.product_4 = self.env.ref('product.product_product_4') + product_product_4 = self.env['product.product'].create(dict( + name="iPad Retina Display", + categ_id=product_category_5.id, + standard_price=500.0, + list_price=750.0, + type="consu", + uom_id=self.env.ref('product.product_uom_unit').id, + uom_po_id=self.env.ref('product.product_uom_unit').id, + description_sale="7.9‑inch (diagonal) LED-backlit, 128Gb Dual-core A5 with quad-core graphics FaceTime HD Camera, 1.2 MP Photos", + default_code="E-COM01", + attribute_value_ids=[(6, 0, [product_attribute_value_1.id, product_attribute_value_3.id])] + )) + self.env['account.invoice.line'].create({ - 'product_id': self.env.ref("product.product_product_4").id, + 'product_id': product_product_4.id, 'quantity': 1, 'price_unit': amount, 'invoice_id': invoice_id.id, diff --git a/addons/account/tests/test_account_supplier_invoice.py b/addons/account/tests/test_account_supplier_invoice.py index 9d3046577d7bba..0e9ecf85717bf0 100644 --- a/addons/account/tests/test_account_supplier_invoice.py +++ b/addons/account/tests/test_account_supplier_invoice.py @@ -17,13 +17,77 @@ def test_supplier_invoice(self): invoice_account = self.env['account.account'].search([('user_type_id', '=', self.env.ref('account.data_account_type_receivable').id)], limit=1).id invoice_line_account = self.env['account.account'].search([('user_type_id', '=', self.env.ref('account.data_account_type_expenses').id)], limit=1).id - invoice = self.env['account.invoice'].create({'partner_id': self.env.ref('base.res_partner_2').id, + res_partner_category_0 = self.env['res.partner.category'].create(dict( + name="Partner", + color=1, + )) + res_partner_category_7 = self.env['res.partner.category'].create(dict( + name="IT Services", + color=5, + parent_id=res_partner_category_0.id + )) + res_partner_category_9 = self.env['res.partner.category'].create(dict( + name="Components Buyer", + color=6 + )) + res_partner_2 = self.env['res.partner'].create(dict( + name="Agrolait", + category_id=[(6, 0, [res_partner_category_7.id, res_partner_category_9.id])], + is_company=True, + city="Wavre", + zip="1300", + country_id=self.env.ref('base.be').id, + street="69 rue de Namur", + email="agrolait@yourcompany.example.com", + phone="+32 10 588 558", + website="http://www.agrolait.com", + property_payment_term_id=self.env.ref('account.account_payment_term_net').id + )) + + invoice = self.env['account.invoice'].create({'partner_id': res_partner_2.id, 'account_id': invoice_account, 'type': 'in_invoice', }) self.assertEquals(invoice.journal_id.type, 'purchase') - self.env['account.invoice.line'].create({'product_id': self.env.ref('product.product_product_4').id, + product_category_5 = self.env['product.category'].create(dict( + parent_id=self.env.ref("product.product_category_1").id, + name="Physical" + )) + + product_attribute_1 = self.env['product.attribute'].create(dict( + name="Memory" + )) + + product_attribute_2 = self.env['product.attribute'].create(dict( + name="Color" + )) + + product_attribute_value_1 = self.env['product.attribute.value'].create(dict( + name="16 GB", + attribute_id=product_attribute_1.id + )) + + product_attribute_value_3 = self.env['product.attribute.value'].create(dict( + name="White", + attribute_id=product_attribute_2.id + )) + + # self.product_4 = self.env.ref('product.product_product_4') + product_product_4 = self.env['product.product'].create(dict( + name="iPad Retina Display", + categ_id=product_category_5.id, + standard_price=500.0, + list_price=750.0, + type="consu", + uom_id=self.env.ref('product.product_uom_unit').id, + uom_po_id=self.env.ref('product.product_uom_unit').id, + description_sale="7.9‑inch (diagonal) LED-backlit, 128Gb Dual-core A5 with quad-core graphics FaceTime HD Camera, 1.2 MP Photos", + default_code="E-COM01", + attribute_value_ids=[(6, 0, [product_attribute_value_1.id, product_attribute_value_3.id])] + )) + + self.env['account.invoice.line'].create({'product_id': product_product_4.id, 'quantity': 1.0, 'price_unit': 100.0, 'invoice_id': invoice.id, @@ -73,13 +137,77 @@ def test_supplier_invoice2(self): invoice_account = self.env['account.account'].search([('user_type_id', '=', self.env.ref('account.data_account_type_receivable').id)], limit=1).id invoice_line_account = self.env['account.account'].search([('user_type_id', '=', self.env.ref('account.data_account_type_expenses').id)], limit=1).id - invoice = self.env['account.invoice'].create({'partner_id': self.env.ref('base.res_partner_2').id, + res_partner_category_0 = self.env['res.partner.category'].create(dict( + name="Partner", + color=1, + )) + res_partner_category_7 = self.env['res.partner.category'].create(dict( + name="IT Services", + color=5, + parent_id=res_partner_category_0.id + )) + res_partner_category_9 = self.env['res.partner.category'].create(dict( + name="Components Buyer", + color=6 + )) + res_partner_2 = self.env['res.partner'].create(dict( + name="Agrolait", + category_id=[(6, 0, [res_partner_category_7.id, res_partner_category_9.id])], + is_company=True, + city="Wavre", + zip="1300", + country_id=self.env.ref('base.be').id, + street="69 rue de Namur", + email="agrolait@yourcompany.example.com", + phone="+32 10 588 558", + website="http://www.agrolait.com", + property_payment_term_id=self.env.ref('account.account_payment_term_net').id + )) + + invoice = self.env['account.invoice'].create({'partner_id': res_partner_2.id, 'account_id': invoice_account, 'type': 'in_invoice', }) self.assertEquals(invoice.journal_id.type, 'purchase') - invoice_line = self.env['account.invoice.line'].create({'product_id': self.env.ref('product.product_product_4').id, + product_category_5 = self.env['product.category'].create(dict( + parent_id=self.env.ref("product.product_category_1").id, + name="Physical" + )) + + product_attribute_1 = self.env['product.attribute'].create(dict( + name="Memory" + )) + + product_attribute_2 = self.env['product.attribute'].create(dict( + name="Color" + )) + + product_attribute_value_1 = self.env['product.attribute.value'].create(dict( + name="16 GB", + attribute_id=product_attribute_1.id + )) + + product_attribute_value_3 = self.env['product.attribute.value'].create(dict( + name="White", + attribute_id=product_attribute_2.id + )) + + # self.product_4 = self.env.ref('product.product_product_4') + product_product_4 = self.env['product.product'].create(dict( + name="iPad Retina Display", + categ_id=product_category_5.id, + standard_price=500.0, + list_price=750.0, + type="consu", + uom_id=self.env.ref('product.product_uom_unit').id, + uom_po_id=self.env.ref('product.product_uom_unit').id, + description_sale="7.9‑inch (diagonal) LED-backlit, 128Gb Dual-core A5 with quad-core graphics FaceTime HD Camera, 1.2 MP Photos", + default_code="E-COM01", + attribute_value_ids=[(6, 0, [product_attribute_value_1.id, product_attribute_value_3.id])] + )) + + invoice_line = self.env['account.invoice.line'].create({'product_id': product_product_4.id, 'quantity': 5.0, 'price_unit': 100.0, 'invoice_id': invoice.id, @@ -121,16 +249,81 @@ def test_vendor_bill_refund(self): 'partner_id': self.env.ref('base.main_partner').id, }) + res_partner_category_0 = self.env['res.partner.category'].create(dict( + name="Partner", + color=1, + )) + res_partner_category_7 = self.env['res.partner.category'].create(dict( + name="IT Services", + color=5, + parent_id=res_partner_category_0.id + )) + res_partner_category_9 = self.env['res.partner.category'].create(dict( + name="Components Buyer", + color=6 + )) + res_partner_2 = self.env['res.partner'].create(dict( + name="Agrolait", + category_id=[(6, 0, [res_partner_category_7.id, res_partner_category_9.id])], + is_company=True, + city="Wavre", + zip="1300", + country_id=self.env.ref('base.be').id, + street="69 rue de Namur", + email="agrolait@yourcompany.example.com", + phone="+32 10 588 558", + website="http://www.agrolait.com", + property_payment_term_id=self.env.ref('account.account_payment_term_net').id + )) + invoice_id = self.env['account.invoice'].create({ 'name': 'invoice test refund', 'reference_type': 'none', - 'partner_id': self.env.ref("base.res_partner_2").id, + 'partner_id': res_partner_2.id, 'account_id': invoice_account.id, 'currency_id': self.env.ref('base.USD').id, 'type': 'in_invoice', }) + + product_category_5 = self.env['product.category'].create(dict( + parent_id=self.env.ref("product.product_category_1").id, + name="Physical" + )) + + product_attribute_1 = self.env['product.attribute'].create(dict( + name="Memory" + )) + + product_attribute_2 = self.env['product.attribute'].create(dict( + name="Color" + )) + + product_attribute_value_1 = self.env['product.attribute.value'].create(dict( + name="16 GB", + attribute_id=product_attribute_1.id + )) + + product_attribute_value_3 = self.env['product.attribute.value'].create(dict( + name="White", + attribute_id=product_attribute_2.id + )) + + # self.product_4 = self.env.ref('product.product_product_4') + product_product_4 = self.env['product.product'].create(dict( + name="iPad Retina Display", + categ_id=product_category_5.id, + standard_price=500.0, + list_price=750.0, + type="consu", + uom_id=self.env.ref('product.product_uom_unit').id, + uom_po_id=self.env.ref('product.product_uom_unit').id, + description_sale="7.9‑inch (diagonal) LED-backlit, 128Gb Dual-core A5 with quad-core graphics FaceTime HD Camera, 1.2 MP Photos", + default_code="E-COM01", + attribute_value_ids=[(6, 0, [product_attribute_value_1.id, product_attribute_value_3.id])] + )) + self.env['account.invoice.line'].create({ - 'product_id': self.env.ref("product.product_product_4").id, + 'product_id': product_product_4.id, 'quantity': 1, 'price_unit': 15.0, 'invoice_id': invoice_id.id, diff --git a/addons/account/tests/test_bank_statement_reconciliation.py b/addons/account/tests/test_bank_statement_reconciliation.py index 7932b32d1fcffc..ed97ce4c931c53 100644 --- a/addons/account/tests/test_bank_statement_reconciliation.py +++ b/addons/account/tests/test_bank_statement_reconciliation.py @@ -8,7 +8,35 @@ def setUp(self): self.il_model = self.env['account.invoice.line'] self.bs_model = self.env['account.bank.statement'] self.bsl_model = self.env['account.bank.statement.line'] - self.partner_agrolait = self.env.ref("base.res_partner_2") + + res_partner_category_0 = self.env['res.partner.category'].create(dict( + name="Partner", + color=1, + )) + res_partner_category_7 = self.env['res.partner.category'].create(dict( + name="IT Services", + color=5, + parent_id=res_partner_category_0.id + )) + res_partner_category_9 = self.env['res.partner.category'].create(dict( + name="Components Buyer", + color=6 + )) + res_partner_2 = self.env['res.partner'].create(dict( + name="Agrolait", + category_id=[(6, 0, [res_partner_category_7.id, res_partner_category_9.id])], + is_company=True, + city="Wavre", + zip="1300", + country_id=self.env.ref('base.be').id, + street="69 rue de Namur", + email="agrolait@yourcompany.example.com", + phone="+32 10 588 558", + website="http://www.agrolait.com", + property_payment_term_id=self.env.ref('account.account_payment_term_net').id + )) + + self.partner_agrolait = res_partner_2 def test_reconciliation_proposition(self): rcv_mv_line = self.create_invoice(100) diff --git a/addons/account/tests/test_payment.py b/addons/account/tests/test_payment.py index 849a882741d538..6cb4a74ea4cc29 100644 --- a/addons/account/tests/test_payment.py +++ b/addons/account/tests/test_payment.py @@ -12,15 +12,101 @@ def setUp(self): self.acc_bank_stmt_model = self.env['account.bank.statement'] self.acc_bank_stmt_line_model = self.env['account.bank.statement.line'] - self.partner_agrolait = self.env.ref("base.res_partner_2") - self.partner_china_exp = self.env.ref("base.res_partner_3") + res_partner_category_0 = self.env['res.partner.category'].create(dict( + name="Partner", + color=1, + )) + res_partner_category_7 = self.env['res.partner.category'].create(dict( + name="IT Services", + color=5, + parent_id=res_partner_category_0.id + )) + res_partner_category_9 = self.env['res.partner.category'].create(dict( + name="Components Buyer", + color=6 + )) + res_partner_2 = self.env['res.partner'].create(dict( + name="Agrolait", + category_id=[(6, 0, [res_partner_category_7.id, res_partner_category_9.id])], + is_company=True, + city="Wavre", + zip="1300", + country_id=self.env.ref('base.be').id, + street="69 rue de Namur", + email="agrolait@yourcompany.example.com", + phone="+32 10 588 558", + website="http://www.agrolait.com", + property_payment_term_id=self.env.ref('account.account_payment_term_net').id + )) + + self.partner_agrolait = res_partner_2 + res_partner_category_8 = self.env['res.partner.category'].create(dict( + name="Consultancy Services", + color=5 + )) + res_partner_category_14 = self.env['res.partner.category'].create(dict( + name="Manufacturer", + color=10 + )) + res_partner_3 = self.env['res.partner'].create(dict( + name="China Export", + supplier=True, + category_id=[(6, 0, [res_partner_category_8.id, res_partner_category_14.id])], + is_company=True, + city="Shanghai", + zip="200000", + country_id=self.env.ref('base.cn').id, + street="52 Chop Suey street", + email="chinaexport@yourcompany.example.com", + phone="+86 21 6484 5671", + website="http://www.chinaexport.com/" + )) + self.partner_china_exp = res_partner_3 self.currency_chf_id = self.env.ref("base.CHF").id self.currency_usd_id = self.env.ref("base.USD").id self.currency_eur_id = self.env.ref("base.EUR").id company = self.env.ref('base.main_company') self.cr.execute("UPDATE res_company SET currency_id = %s WHERE id = %s", [self.currency_eur_id, company.id]) - self.product = self.env.ref("product.product_product_4") + + product_category_5 = self.env['product.category'].create(dict( + parent_id=self.env.ref("product.product_category_1").id, + name="Physical" + )) + + product_attribute_1 = self.env['product.attribute'].create(dict( + name="Memory" + )) + + product_attribute_2 = self.env['product.attribute'].create(dict( + name="Color" + )) + + product_attribute_value_1 = self.env['product.attribute.value'].create(dict( + name="16 GB", + attribute_id=product_attribute_1.id + )) + + product_attribute_value_3 = self.env['product.attribute.value'].create(dict( + name="White", + attribute_id=product_attribute_2.id + )) + + # self.product_4 = self.env.ref('product.product_product_4') + product_product_4 = self.env['product.product'].create(dict( + name="iPad Retina Display", + categ_id=product_category_5.id, + standard_price=500.0, + list_price=750.0, + type="consu", + uom_id=self.env.ref('product.product_uom_unit').id, + uom_po_id=self.env.ref('product.product_uom_unit').id, + description_sale="7.9‑inch (diagonal) LED-backlit, 128Gb Dual-core A5 with quad-core graphics FaceTime HD Camera, 1.2 MP Photos", + default_code="E-COM01", + attribute_value_ids=[(6, 0, [product_attribute_value_1.id, product_attribute_value_3.id])] + )) + + self.product = product_product_4 self.payment_method_manual_in = self.env.ref("account.account_payment_method_manual_in") self.payment_method_manual_out = self.env.ref("account.account_payment_method_manual_out") diff --git a/addons/account/tests/test_reconciliation.py b/addons/account/tests/test_reconciliation.py index 9b7e4edeabcd68..085519c8693a0c 100644 --- a/addons/account/tests/test_reconciliation.py +++ b/addons/account/tests/test_reconciliation.py @@ -21,7 +21,34 @@ def setUp(self): self.res_currency_model = self.registry('res.currency') self.res_currency_rate_model = self.registry('res.currency.rate') - partner_agrolait = self.env.ref("base.res_partner_2") + res_partner_category_0 = self.env['res.partner.category'].create(dict( + name="Partner", + color=1, + )) + res_partner_category_7 = self.env['res.partner.category'].create(dict( + name="IT Services", + color=5, + parent_id=res_partner_category_0.id + )) + res_partner_category_9 = self.env['res.partner.category'].create(dict( + name="Components Buyer", + color=6 + )) + res_partner_2 = self.env['res.partner'].create(dict( + name="Agrolait", + category_id=[(6, 0, [res_partner_category_7.id, res_partner_category_9.id])], + is_company=True, + city="Wavre", + zip="1300", + country_id=self.env.ref('base.be').id, + street="69 rue de Namur", + email="agrolait@yourcompany.example.com", + phone="+32 10 588 558", + website="http://www.agrolait.com", + property_payment_term_id=self.env.ref('account.account_payment_term_net').id + )) + + partner_agrolait = res_partner_2 self.partner_agrolait_id = partner_agrolait.id self.currency_swiss_id = self.env.ref("base.CHF").id self.currency_usd_id = self.env.ref("base.USD").id @@ -30,7 +57,45 @@ def setUp(self): self.cr.execute("UPDATE res_company SET currency_id = %s WHERE id = %s", [self.currency_euro_id, company.id]) self.account_rcv = partner_agrolait.property_account_receivable_id or self.env['account.account'].search([('user_type_id', '=', self.env.ref('account.data_account_type_receivable').id)], limit=1) self.account_rsa = partner_agrolait.property_account_payable_id or self.env['account.account'].search([('user_type_id', '=', self.env.ref('account.data_account_type_payable').id)], limit=1) - self.product = self.env.ref("product.product_product_4") + + product_category_5 = self.env['product.category'].create(dict( + parent_id=self.env.ref("product.product_category_1").id, + name="Physical" + )) + + product_attribute_1 = self.env['product.attribute'].create(dict( + name="Memory" + )) + + product_attribute_2 = self.env['product.attribute'].create(dict( + name="Color" + )) + + product_attribute_value_1 = self.env['product.attribute.value'].create(dict( + name="16 GB", + attribute_id=product_attribute_1.id + )) + + product_attribute_value_3 = self.env['product.attribute.value'].create(dict( + name="White", + attribute_id=product_attribute_2.id + )) + + # self.product_4 = self.env.ref('product.product_product_4') + product_product_4 = self.env['product.product'].create(dict( + name="iPad Retina Display", + categ_id=product_category_5.id, + standard_price=500.0, + list_price=750.0, + type="consu", + uom_id=self.env.ref('product.product_uom_unit').id, + uom_po_id=self.env.ref('product.product_uom_unit').id, + description_sale="7.9‑inch (diagonal) LED-backlit, 128Gb Dual-core A5 with quad-core graphics FaceTime HD Camera, 1.2 MP Photos", + default_code="E-COM01", + attribute_value_ids=[(6, 0, [product_attribute_value_1.id, product_attribute_value_3.id])] + )) + + self.product = product_product_4 self.bank_journal_euro = self.env['account.journal'].create({'name': 'Bank', 'type': 'bank', 'code': 'BNK67'}) self.account_euro = self.bank_journal_euro.default_debit_account_id diff --git a/addons/auth_signup/controllers/main.py b/addons/auth_signup/controllers/main.py index 68c996c82db78f..2b083216b76169 100644 --- a/addons/auth_signup/controllers/main.py +++ b/addons/auth_signup/controllers/main.py @@ -5,7 +5,7 @@ from odoo import http, _ from odoo.addons.auth_signup.models.res_users import SignupError -from odoo.addons.web.controllers.main import ensure_db, Home +from odoo.addons.web.controllers.main import ensure_db, Home, SIGN_UP_REQUEST_PARAMS from odoo.exceptions import UserError from odoo.http import request @@ -100,7 +100,7 @@ def get_auth_signup_config(self): def get_auth_signup_qcontext(self): """ Shared helper returning the rendering context for signup and reset password """ - qcontext = request.params.copy() + qcontext = {k: v for (k, v) in request.params.items() if k in SIGN_UP_REQUEST_PARAMS} qcontext.update(self.get_auth_signup_config()) if not qcontext.get('token') and request.session.get('auth_signup_token'): qcontext['token'] = request.session.get('auth_signup_token') diff --git a/addons/delivery/tests/test_delivery_cost.py b/addons/delivery/tests/test_delivery_cost.py index 343443941c9554..967971349d256a 100644 --- a/addons/delivery/tests/test_delivery_cost.py +++ b/addons/delivery/tests/test_delivery_cost.py @@ -16,17 +16,171 @@ def setUp(self): self.SaleConfigSetting = self.env['res.config.settings'] self.Product = self.env['product.product'] - self.partner_18 = self.env.ref('base.res_partner_18') + res_partner_category_0 = self.env['res.partner.category'].create(dict( + name="Partner", + color=1 + )) + + res_partner_category_5 = self.env['res.partner.category'].create(dict( + name="Silver", + color=3, + parent_id=res_partner_category_0.id + )) + + # self.partner_18 = self.env.ref('base.res_partner_18') + res_partner_18 = self.env['res.partner'].create(dict( + name="Think Big Systems", + is_company=True, + category_id=[(6, 0, [res_partner_category_5.id])], + city="London", + email="thinkbig@yourcompany.example.com", + phone="+1 857 349 3049", + country_id=self.env.ref('base.uk').id, + street="89 Lingfield Tower", + website="http://www.think-big.com" + )) + self.partner_18 = res_partner_18 + self.pricelist = self.env.ref('product.list0') - self.product_4 = self.env.ref('product.product_product_4') + + product_category_5 = self.env['product.category'].create(dict( + parent_id=self.env.ref("product.product_category_1").id, + name="Physical" + )) + + product_attribute_1 = self.env['product.attribute'].create(dict( + name="Memory" + )) + + product_attribute_2 = self.env['product.attribute'].create(dict( + name="Color" + )) + + product_attribute_value_1 = self.env['product.attribute.value'].create(dict( + name="16 GB", + attribute_id=product_attribute_1.id + )) + + product_attribute_value_3 = self.env['product.attribute.value'].create(dict( + name="White", + attribute_id=product_attribute_2.id + )) + self.product_uom_unit = self.env.ref('product.product_uom_unit') - self.normal_delivery = self.env.ref('delivery.normal_delivery_carrier') - self.partner_4 = self.env.ref('base.res_partner_4') - self.partner_address_13 = self.env.ref('base.res_partner_address_13') + + # self.product_4 = self.env.ref('product.product_product_4') + self.product_4 = self.env['product.product'].create(dict( + name="iPad Retina Display", + categ_id=product_category_5.id, + standard_price=500.0, + list_price=750.0, + type="consu", + uom_id=self.product_uom_unit.id, + uom_po_id=self.product_uom_unit.id, + description_sale="7.9‑inch (diagonal) LED-backlit, 128Gb Dual-core A5 with quad-core graphics FaceTime HD Camera, 1.2 MP Photos", + default_code="E-COM01", + attribute_value_ids=[(6, 0, [product_attribute_value_1.id, product_attribute_value_3.id])] + )) + + product_product_delivery_normal = self.env['product.product'].create(dict( + name="Normal Delivery Charges", + default_code="Delivery", + type="service", + categ_id=self.env.ref('product.product_category_all').id, + sale_ok=False, + purchase_ok=False, + list_price=10.0 + )) + + # self.normal_delivery = self.env.ref('delivery.normal_delivery_carrier') + self.normal_delivery = self.env['delivery.carrier'].create(dict( + name="Normal Delivery Charges", + fixed_price=10.0, + sequence=3, + delivery_type="fixed", + product_id=product_product_delivery_normal.id + )) + + res_partner_category_12 = self.env['res.partner.category'].create(dict( + name="Office Supplies", + color=8 + )) + + res_partner_category_13 = self.env['res.partner.category'].create(dict( + name="Distributor", + color=9 + )) + + # self.partner_4 = self.env.ref('base.res_partner_4') + self.partner_4 = self.env['res.partner'].create(dict( + name="Delta PC", + category_id=[(6, 0, [res_partner_category_13.id, res_partner_category_12.id])], + customer=False, + supplier=True, + is_company=True, + city="Fremont", + zip="94538", + country_id=self.env.ref('base.us').id, + state_id=self.env['res.country.state'].search([('code', 'ilike', 'ca')], limit=1).id, + street="3661 Station Street", + email="deltapc@yourcompany.example.com", + phone="+1 510 340 2385", + website="http://www.distribpc.com/" + )) + + res_partner_category_8 = self.env['res.partner.category'].create(dict( + name="Consultancy Services", + color=5 + )) + + res_partner_category_14 = self.env['res.partner.category'].create(dict( + name="Manufacturer", + color=10 + )) + + res_partner_3 = self.env['res.partner'].create(dict( + name="China Export", + supplier=True, + category_id=[(6, 0, [res_partner_category_8.id, res_partner_category_14.id])], + is_company=True, + city="Shanghai", + zip="200000", + country_id=self.env.ref('base.cn').id, + street="52 Chop Suey street", + email="chinaexport@yourcompany.example.com", + phone="+86 21 6484 5671", + website="http://www.chinaexport.com/" + )) + + # self.partner_address_13 = self.env.ref('base.res_partner_address_13') + self.partner_address_13 = self.env['res.partner'].create(dict( + name="John M. Brown", + parent_id=res_partner_3.id, + function="Director", + email="john.brown@epic.example.com" + )) + self.product_uom_hour = self.env.ref('product.product_uom_hour') self.account_data = self.env.ref('account.data_account_type_revenue') self.account_tag_operating = self.env.ref('account.account_tag_operating') - self.product_2 = self.env.ref('product.product_product_2') + + product_category_3 = self.env['product.category'].create(dict( + parent_id=self.env.ref('product.product_category_1').id, + name="Services" + )) + + # self.product_2 = self.env.ref('product.product_product_2') + self.product_2 = self.env['product.product'].create(dict( + name="Support Services", + categ_id=product_category_3.id, + standard_price=25.5, + list_price=38.25, + type="service", + uom_id=self.env.ref('product.product_uom_hour').id, + uom_po_id=self.env.ref('product.product_uom_hour').id, + description="Example of product to invoice based on delivery." + )) + self.product_category = self.env.ref('product.product_category_all') self.free_delivery = self.env.ref('delivery.free_delivery_carrier') # as the tests hereunder assume all the prices in USD, we must ensure @@ -34,7 +188,8 @@ def setUp(self): self.env.cr.execute( "UPDATE res_company SET currency_id = %s WHERE id = %s", [self.env.ref('base.USD').id, self.env.user.company_id.id]) - self.pricelist.currency_id = self.env.ref('base.USD').id + # FIXME: this is failing due to product.pricelist constraint + # self.pricelist.currency_id = self.env.ref('base.USD').id def test_00_delivery_cost(self): # In order to test Carrier Cost diff --git a/addons/delivery/tests/test_delivery_stock_move.py b/addons/delivery/tests/test_delivery_stock_move.py index 81e66e3314d5cc..a3361c9110f853 100644 --- a/addons/delivery/tests/test_delivery_stock_move.py +++ b/addons/delivery/tests/test_delivery_stock_move.py @@ -11,12 +11,84 @@ def setUp(self): self.SaleOrder = self.env['sale.order'] self.AccountJournal = self.env['account.journal'] - self.partner_18 = self.env.ref('base.res_partner_18') + res_partner_category_0 = self.env['res.partner.category'].create(dict( + name="Partner", + color=1 + )) + + res_partner_category_5 = self.env['res.partner.category'].create(dict( + name="Silver", + color=3, + parent_id=res_partner_category_0.id + )) + res_partner_18 = self.env['res.partner'].create(dict( + name="Think Big Systems", + is_company=True, + category_id=[(6, 0, [res_partner_category_5.id])], + city="London", + email="thinkbig@yourcompany.example.com", + phone="+1 857 349 3049", + country_id=self.env.ref('base.uk').id, + street="89 Lingfield Tower", + website="http://www.think-big.com" + )) + self.partner_18 = res_partner_18 self.pricelist_id = self.env.ref('product.list0') - self.product_11 = self.env.ref('product.product_product_11') - self.product_icecream = self.env.ref('stock.product_icecream') + product_category_5 = self.env['product.category'].create(dict( + parent_id=self.env.ref('product.product_category_1').id, + name="Physical" + )) + product_attribute_1 = self.env['product.attribute'].create(dict( + name="Memory" + )) + product_attribute_value_1 = self.env['product.attribute.value'].create(dict( + name="16 GB", + attribute_id=product_attribute_1.id + )) + product_product_11 = self.env['product.product'].create(dict( + name="iPod", + categ_id=product_category_5.id, + standard_price=14, + list_price=16.50, + type="consu", + uom_id=self.env.ref('product.product_uom_unit').id, + uom_po_id=self.env.ref('product.product_uom_unit').id, + default_code="E-COM12", + attribute_value_ids=[(6,0,[product_attribute_value_1.id])] + )) + self.product_11 = product_product_11 + product_icecream = self.env['product.product'].create(dict( + default_code="001", + name="Ice Cream", + type="product", + categ_id=self.env.ref('product.product_category_1').id, + list_price=100.0, + standard_price=70.0, + weight=1.0, + uom_id=self.env.ref('product.product_uom_kgm').id, + uom_po_id=self.env.ref('product.product_uom_kgm').id, + property_stock_inventory=self.env.ref('stock.location_inventory').id, + description="Ice cream can be mass-produced and thus is widely available in developed parts of the world. Ice cream can be purchased in large cartons (vats and squrounds) from supermarkets and grocery stores, in smaller quantities from ice cream shops, convenience stores, and milk bars, and in individual servings from small carts or vans at public events." + )) + self.product_icecream = product_icecream self.product_uom_kgm = self.env.ref('product.product_uom_kgm') - self.normal_delivery = self.env.ref('delivery.normal_delivery_carrier') + product_product_delivery_normal = self.env['product.product'].create(dict( + default_code="Delivery", + name="Normal Delivery Charges", + type="service", + categ_id=self.env.ref('product.product_category_all').id, + list_price=10.0, + sale_ok=False, + purchase_ok=False + )) + normal_delivery_carrier = self.env['delivery.carrier'].create(dict( + name="Normal Delivery Charges", + fixed_price=10.0, + sequence=3, + delivery_type="fixed", + product_id=product_product_delivery_normal.id + )) + self.normal_delivery = normal_delivery_carrier def test_01_delivery_stock_move(self): # Test if the stored fields of stock moves are computed with invoice before delivery flow diff --git a/addons/l10n_fr_fec/wizard/account_fr_fec.py b/addons/l10n_fr_fec/wizard/account_fr_fec.py index 90b5288c71af6c..3e7e1281fdeeb9 100644 --- a/addons/l10n_fr_fec/wizard/account_fr_fec.py +++ b/addons/l10n_fr_fec/wizard/account_fr_fec.py @@ -8,10 +8,11 @@ from datetime import datetime from odoo import api, fields, models, _ -from odoo.exceptions import Warning +from odoo.exceptions import Warning, AccessDenied from odoo.tools import float_is_zero, pycompat, DEFAULT_SERVER_DATE_FORMAT + class AccountFrFec(models.TransientModel): _name = 'account.fr.fec' _description = 'Ficher Echange Informatise' @@ -25,7 +26,7 @@ class AccountFrFec(models.TransientModel): ('nonofficial', 'Non-official FEC report (posted and unposted entries)'), ], string='Export Type', required=True, default='official') - def do_query_unaffected_earnings(self): + def _do_query_unaffected_earnings(self): ''' Compute the sum of ending balances for all accounts that are of a type that does not bring forward the balance in new fiscal years. This is needed because we have to display only one line for the initial balance of all expense/revenue accounts in the FEC. ''' @@ -101,6 +102,8 @@ def _get_company_legal_data(self, company): @api.multi def generate_fec(self): self.ensure_one() + if not (self.env.is_admin() or self.env.user.has_group('account.group_account_user')): + raise AccessDenied() # We choose to implement the flat file instead of the XML # file for 2 reasons : # 1) the XSD file impose to have the label on the account.move @@ -139,7 +142,7 @@ def generate_fec(self): unaffected_earnings_line = True # used to make sure that we add the unaffected earning initial balance only once if unaffected_earnings_xml_ref: #compute the benefit/loss of last year to add in the initial balance of the current year earnings account - unaffected_earnings_results = self.do_query_unaffected_earnings() + unaffected_earnings_results = self._do_query_unaffected_earnings() unaffected_earnings_line = False sql_query = ''' diff --git a/addons/purchase/tests/test_create_picking.py b/addons/purchase/tests/test_create_picking.py index a7a7330b60a289..13a2679e3d839d 100644 --- a/addons/purchase/tests/test_create_picking.py +++ b/addons/purchase/tests/test_create_picking.py @@ -10,9 +10,64 @@ class TestCreatePicking(common.TestProductCommon): def setUp(self): super(TestCreatePicking, self).setUp() - self.partner_id = self.env.ref('base.res_partner_1') - self.product_id_1 = self.env.ref('product.product_product_8') - self.product_id_2 = self.env.ref('product.product_product_11') + res_partner_category_13 = self.env['res.partner.category'].create(dict( + name="Distributor", + color=9 + )) + res_partner_category_12 = self.env['res.partner.category'].create(dict( + name="Office Supplies", + color=8 + )) + res_partner_1 = self.env['res.partner'].create(dict( + name="ASUSTeK", + category_id=[(6, 0, [res_partner_category_13.id, res_partner_category_12.id])], + supplier=True, + customer=False, + is_company=True, + city="Taipei", + zip="106", + country_id=self.env.ref('base.tw').id, + street="1 Hong Kong street", + email="asusteK@yourcompany.example.com", + phone="(+886) (02) 4162 2023", + website="http://www.asustek.com" + )) + self.partner_id = res_partner_1 + product_category_5 = self.env['product.category'].create(dict( + parent_id=self.env.ref('product.product_category_1').id, + name="Physical" + )) + product_product_8 = self.env['product.product'].create(dict( + name="iMac", + categ_id=product_category_5.id, + standard_price=1299.0, + list_price=1799.0, + type="consu", + uom_id=self.env.ref('product.product_uom_unit').id, + uom_po_id=self.env.ref('product.product_uom_unit').id, + default_code="E-COM09", + weight="9.54" + )) + self.product_id_1 = product_product_8 + product_attribute_1 = self.env['product.attribute'].create(dict( + name="Memory" + )) + product_attribute_value_1 = self.env['product.attribute.value'].create(dict( + name="16 GB", + attribute_id=product_attribute_1.id + )) + product_product_11 = self.env['product.product'].create(dict( + name="iPod", + categ_id=product_category_5.id, + standard_price=14, + list_price=16.50, + type="consu", + uom_id=self.env.ref('product.product_uom_unit').id, + uom_po_id=self.env.ref('product.product_uom_unit').id, + default_code="E-COM12", + attribute_value_ids=[(6,0,[product_attribute_value_1.id])] + )) + self.product_id_2 = product_product_11 res_users_purchase_user = self.env.ref('purchase.group_purchase_user') Users = self.env['res.users'].with_context({'no_reset_password': True, 'mail_create_nosubscribe': True}) diff --git a/addons/purchase/tests/test_purchase_order.py b/addons/purchase/tests/test_purchase_order.py index edab672a214247..ea3aa117007e25 100644 --- a/addons/purchase/tests/test_purchase_order.py +++ b/addons/purchase/tests/test_purchase_order.py @@ -16,9 +16,64 @@ def setUp(self): self.PurchaseOrderLine = self.env['purchase.order.line'] self.AccountInvoice = self.env['account.invoice'] self.AccountInvoiceLine = self.env['account.invoice.line'] - self.partner_id = self.env.ref('base.res_partner_1') - self.product_id_1 = self.env.ref('product.product_product_8') - self.product_id_2 = self.env.ref('product.product_product_11') + res_partner_category_13 = self.env['res.partner.category'].create(dict( + name="Distributor", + color=9 + )) + res_partner_category_12 = self.env['res.partner.category'].create(dict( + name="Office Supplies", + color=8 + )) + res_partner_1 = self.env['res.partner'].create(dict( + name="ASUSTeK", + category_id=[(6, 0, [res_partner_category_13.id, res_partner_category_12.id])], + supplier=True, + customer=False, + is_company=True, + city="Taipei", + zip="106", + country_id=self.env.ref('base.tw').id, + street="1 Hong Kong street", + email="asusteK@yourcompany.example.com", + phone="(+886) (02) 4162 2023", + website="http://www.asustek.com" + )) + self.partner_id = res_partner_1 + product_category_5 = self.env['product.category'].create(dict( + parent_id=self.env.ref('product.product_category_1').id, + name="Physical" + )) + product_product_8 = self.env['product.product'].create(dict( + name="iMac", + categ_id=product_category_5.id, + standard_price=1299.0, + list_price=1799.0, + type="consu", + uom_id=self.env.ref('product.product_uom_unit').id, + uom_po_id=self.env.ref('product.product_uom_unit').id, + default_code="E-COM09", + weight="9.54" + )) + self.product_id_1 = product_product_8 + product_attribute_1 = self.env['product.attribute'].create(dict( + name="Memory" + )) + product_attribute_value_1 = self.env['product.attribute.value'].create(dict( + name="16 GB", + attribute_id=product_attribute_1.id + )) + product_product_11 = self.env['product.product'].create(dict( + name="iPod", + categ_id=product_category_5.id, + standard_price=14, + list_price=16.50, + type="consu", + uom_id=self.env.ref('product.product_uom_unit').id, + uom_po_id=self.env.ref('product.product_uom_unit').id, + default_code="E-COM12", + attribute_value_ids=[(6,0,[product_attribute_value_1.id])] + )) + self.product_id_2 = product_product_11 (self.product_id_1 | self.product_id_2).write({'purchase_method': 'purchase'}) self.po_vals = { diff --git a/addons/purchase/tests/test_stockvaluation.py b/addons/purchase/tests/test_stockvaluation.py index 90225498185667..da1b85028f474a 100644 --- a/addons/purchase/tests/test_stockvaluation.py +++ b/addons/purchase/tests/test_stockvaluation.py @@ -15,7 +15,28 @@ def setUp(self): super(TestStockValuation, self).setUp() self.supplier_location = self.env.ref('stock.stock_location_suppliers') self.stock_location = self.env.ref('stock.stock_location_stock') - self.partner_id = self.env.ref('base.res_partner_1') + res_partner_category_13 = self.env['res.partner.category'].create(dict( + name="Distributor", + color=9 + )) + res_partner_category_12 = self.env['res.partner.category'].create(dict( + name="Office Supplies", + color=8 + )) + self.partner_id = self.env['res.partner'].create(dict( + name="ASUSTeK", + category_id=[(6, 0, [res_partner_category_13.id, res_partner_category_12.id])], + supplier=True, + customer=False, + is_company=True, + city="Taipei", + zip="106", + country_id=self.env.ref('base.tw').id, + street="1 Hong Kong street", + email="asusteK@yourcompany.example.com", + phone="(+886) (02) 4162 2023", + website="http://www.asustek.com" + )) self.product1 = self.env.ref('product.product_product_8') Account = self.env['account.account'] self.stock_input_account = Account.create({ @@ -280,8 +301,45 @@ def setUp(self): super(TestStockValuationWithCOA, self).setUp() self.supplier_location = self.env.ref('stock.stock_location_suppliers') self.stock_location = self.env.ref('stock.stock_location_stock') - self.partner_id = self.env.ref('base.res_partner_1') - self.product1 = self.env.ref('product.product_product_8') + res_partner_category_13 = self.env['res.partner.category'].create(dict( + name="Distributor", + color=9 + )) + res_partner_category_12 = self.env['res.partner.category'].create(dict( + name="Office Supplies", + color=8 + )) + res_partner_1 = self.env['res.partner'].create(dict( + name="ASUSTeK", + category_id=[(6, 0, [res_partner_category_13.id, res_partner_category_12.id])], + supplier=True, + customer=False, + is_company=True, + city="Taipei", + zip="106", + country_id=self.env.ref('base.tw').id, + street="1 Hong Kong street", + email="asusteK@yourcompany.example.com", + phone="(+886) (02) 4162 2023", + website="http://www.asustek.com" + )) + self.partner_id = res_partner_1 + product_category_5 = self.env['product.category'].create(dict( + parent_id=self.env.ref('product.product_category_1').id, + name="Physical" + )) + product_product_8 = self.env['product.product'].create(dict( + name="iMac", + categ_id=product_category_5.id, + standard_price=1299.0, + list_price=1799.0, + type="consu", + uom_id=self.env.ref('product.product_uom_unit').id, + uom_po_id=self.env.ref('product.product_uom_unit').id, + default_code="E-COM09", + weight="9.54" + )) + self.product1 = product_product_8 Account = self.env['account.account'] self.usd_currency = self.env.ref('base.USD') self.eur_currency = self.env.ref('base.EUR') diff --git a/addons/sale/tests/test_sale_common.py b/addons/sale/tests/test_sale_common.py index ebea8f85c5f245..4312bb0aaa562f 100644 --- a/addons/sale/tests/test_sale_common.py +++ b/addons/sale/tests/test_sale_common.py @@ -27,11 +27,85 @@ def setUp(self): 'groups_id': [(6, 0, [group_user.id])] }) # create quotation with differend kinds of products (all possible combinations) + product_category_4 = self.env['product.category'].create(dict( + parent_id=self.env.ref('product.product_category_1').id, + name="Software" + )) + product_order_01 = self.env['product.product'].create(dict( + name="Zed+ Antivirus", + categ_id=product_category_4.id, + standard_price=235.0, + list_price=280.0, + type="consu", + uom_id=self.env.ref('product.product_uom_unit').id, + uom_po_id=self.env.ref('product.product_uom_unit').id, + default_code="PROD_ORDER" + )) + product_category_5 = self.env['product.category'].create(dict( + parent_id=self.env.ref('product.product_category_1').id, + name="Physical" + )) + service_delivery = self.env['product.product'].create(dict( + name="Cost-plus Contract", + categ_id=product_category_5.id, + standard_price=200.0, + list_price=180.0, + type="service", + uom_id=self.env.ref('product.product_uom_unit').id, + uom_po_id=self.env.ref('product.product_uom_unit').id, + default_code="SERV_DEL" + )) + product_category_3 = self.env['product.category'].create(dict( + parent_id=self.env.ref('product.product_category_1').id, + name="Services" + )) + service_order_01 = self.env['product.product'].create(dict( + name="Prepaid Consulting", + categ_id=product_category_3.id, + standard_price=40, + list_price=90, + type="service", + uom_id=self.env.ref('product.product_uom_hour').id, + uom_po_id=self.env.ref('product.product_uom_hour').id, + description="Example of product to invoice on order.", + default_code="SERV_ORDER" + )) + product_delivery_01 = self.env['product.product'].create(dict( + name="Switch, 24 ports", + categ_id=product_category_5.id, + standard_price=55.0, + list_price=70.0, + type="consu", + uom_id=self.env.ref('product.product_uom_unit').id, + uom_po_id=self.env.ref('product.product_uom_unit').id, + default_code="PROD_DEL" + )) self.products = OrderedDict([ - ('prod_order', self.env.ref('product.product_order_01')), - ('serv_del', self.env.ref('product.service_delivery')), - ('serv_order', self.env.ref('product.service_order_01')), - ('prod_del', self.env.ref('product.product_delivery_01')), + ('prod_order', product_order_01), + ('serv_del', service_delivery), + ('serv_order', service_order_01), + ('prod_del', product_delivery_01), ]) - - self.partner = self.env.ref('base.res_partner_1') + res_partner_category_13 = self.env['res.partner.category'].create(dict( + name="Distributor", + color=9 + )) + res_partner_category_12 = self.env['res.partner.category'].create(dict( + name="Office Supplies", + color=8 + )) + res_partner_1 = self.env['res.partner'].create(dict( + name="ASUSTeK", + category_id=[(6, 0, [res_partner_category_13.id, res_partner_category_12.id])], + supplier=True, + customer=False, + is_company=True, + city="Taipei", + zip="106", + country_id=self.env.ref('base.tw').id, + street="1 Hong Kong street", + email="asusteK@yourcompany.example.com", + phone="(+886) (02) 4162 2023", + website="http://www.asustek.com" + )) + self.partner = res_partner_1 diff --git a/addons/sale/tests/test_sale_order.py b/addons/sale/tests/test_sale_order.py index e87775076f964f..6ae97299111604 100644 --- a/addons/sale/tests/test_sale_order.py +++ b/addons/sale/tests/test_sale_order.py @@ -111,8 +111,35 @@ def test_cost_invoicing(self): # force the pricelist to have the same currency as the company self.env.ref('product.list0').currency_id = self.env.ref('base.main_company').currency_id - serv_cost = self.env.ref('product.service_cost_01') - prod_gap = self.env.ref('product.product_product_1') + product_category_3 = self.env['product.category'].create(dict( + parent_id=self.env.ref('product.product_category_1').id, + name="Services" + )) + service_cost_01 = self.env['product.product'].create(dict( + name="External Audit", + categ_id=product_category_3.id, + standard_price=160, + list_price=180, + type="service", + uom_id=self.env.ref('product.product_uom_unit').id, + uom_po_id = self.env.ref('product.product_uom_unit').id, + description="Example of products to invoice based on cost.", + default_code="SERV_COST", + expense_policy="cost" + )) + serv_cost = service_cost_01 + product_product_1 = self.env['product.product'].create(dict( + name="GAP Analysis Service", + categ_id=product_category_3.id, + standard_price=20.5, + list_price=30.75, + type="service", + uom_id=self.env.ref('product.product_uom_hour').id, + uom_po_id=self.env.ref('product.product_uom_hour').id, + description="Example of products to invoice based on delivery.", + invoice_policy="delivery" + )) + prod_gap = product_product_1 so = self.env['sale.order'].create({ 'partner_id': self.partner.id, 'partner_invoice_id': self.partner.id, @@ -122,7 +149,33 @@ def test_cost_invoicing(self): }) so.action_confirm() so._create_analytic_account() - inv_partner = self.env.ref('base.res_partner_2') + res_partner_category_0 = self.env['res.partner.category'].create(dict( + name="Partner", + color=1, + )) + res_partner_category_7 = self.env['res.partner.category'].create(dict( + name="IT Services", + color=5, + parent_id=res_partner_category_0.id + )) + res_partner_category_9 = self.env['res.partner.category'].create(dict( + name="Components Buyer", + color=6 + )) + res_partner_2 = self.env['res.partner'].create(dict( + name="Agrolait", + category_id=[(6, 0, [res_partner_category_7.id, res_partner_category_9.id])], + is_company=True, + city="Wavre", + zip="1300", + country_id=self.env.ref('base.be').id, + street="69 rue de Namur", + email="agrolait@yourcompany.example.com", + phone="+32 10 588 558", + website="http://www.agrolait.com", + property_payment_term_id=self.env.ref('account.account_payment_term_net').id + )) + inv_partner = res_partner_2 company = self.env.ref('base.main_company') journal = self.env['account.journal'].create({'name': 'Purchase Journal - Test', 'code': 'STPJ', 'type': 'purchase', 'company_id': company.id}) account_payable = self.env['account.account'].create({'code': 'X1111', 'name': 'Sale - Test Payable Account', 'user_type_id': self.env.ref('account.data_account_type_payable').id, 'reconcile': True}) @@ -149,7 +202,28 @@ def test_so_create_multicompany(self): which would mean that taxes from all child companies would end up on the order lines. """ - user_demo = self.env.ref('base.user_demo') + main_company=self.env['res.company'].create(dict( + name="YourCompany", + external_report_layout="standard" + )) + partner_demo=self.env['res.partner'].create(dict( + name="Demo User", + company_id=main_company.id, + customer=False, + email="demo@yourcompany.example.com", + company_name="YourCompany", + street="Avenue des Dessus-de-Lives, 2", + city="Namur (Loyers)", + zip="5101", + country_id=self.env.ref('base.be').id + )) + user_demo = self.env['res.users'].create(dict( + partner_id=partner_demo.id, + login="demo", + password="demo", + company_id=main_company.id, + groups_id=[(6, 0, [self.env.ref('base.group_user'), self.env.ref('base.group_partner_manager')])] + )) company_1 = self.env.ref('base.main_company') company_2 = self.env['res.company'].create({ 'name': 'company 2', @@ -173,8 +247,35 @@ def test_so_create_multicompany(self): 'taxes_id': [(6, False, [tax_company_1.id, tax_company_2.id])], }) + res_partner_category_0 = self.env['res.partner.category'].create(dict( + name="Partner", + color=1, + )) + res_partner_category_7 = self.env['res.partner.category'].create(dict( + name="IT Services", + color=5, + parent_id=res_partner_category_0.id + )) + res_partner_category_9 = self.env['res.partner.category'].create(dict( + name="Components Buyer", + color=6 + )) + res_partner_2 = self.env['res.partner'].create(dict( + name="Agrolait", + category_id=[(6, 0, [res_partner_category_7.id, res_partner_category_9.id])], + is_company=True, + city="Wavre", + zip="1300", + country_id=self.env.ref('base.be').id, + street="69 rue de Namur", + email="agrolait@yourcompany.example.com", + phone="+32 10 588 558", + website="http://www.agrolait.com", + property_payment_term_id=self.env.ref('account.account_payment_term_net').id + )) + so_1 = self.env['sale.order'].sudo(user_demo.id).create({ - 'partner_id': self.env.ref('base.res_partner_2').id, + 'partner_id': res_partner_2.id, 'company_id': company_1.id, }) so_1.write({ diff --git a/addons/sale/tests/test_sale_to_invoice_and_to_be_invoiced.py b/addons/sale/tests/test_sale_to_invoice_and_to_be_invoiced.py index c7df57978b9758..c2146d09002cb3 100644 --- a/addons/sale/tests/test_sale_to_invoice_and_to_be_invoiced.py +++ b/addons/sale/tests/test_sale_to_invoice_and_to_be_invoiced.py @@ -6,14 +6,71 @@ class TestSaleOrderInvoicing(AccountingTestCase): + def setUp(self): + super(TestSaleOrderInvoicing, self).setUp() + res_partner_category_13 = self.env['res.partner.category'].create(dict( + name="Distributor", + color=9 + )) + res_partner_category_12 = self.env['res.partner.category'].create(dict( + name="Office Supplies", + color=8 + )) + self.res_partner_1 = self.env['res.partner'].create(dict( + name="ASUSTeK", + category_id=[(6, 0, [res_partner_category_13.id, res_partner_category_12.id])], + supplier=True, + customer=False, + is_company=True, + city="Taipei", + zip="106", + country_id=self.env.ref('base.tw').id, + street="1 Hong Kong street", + email="asusteK@yourcompany.example.com", + phone="(+886) (02) 4162 2023", + website="http://www.asustek.com" + )) + def test_sale_to_invoice_and_to_be_invoiced(self): """ Testing amount to invoice and amount to be invoiced, with advances. """ - - partner = self.env.ref('base.res_partner_1') + partner = self.res_partner_1 partner.property_account_receivable_id = self.env['account.account'].search( [('user_type_id', '=', self.env.ref('account.data_account_type_revenue').id)], limit=1) - product_1 = self.env.ref('product.product_product_8') - product_2 = self.env.ref('product.product_product_11') + product_category_5 = self.env['product.category'].create(dict( + parent_id=self.env.ref('product.product_category_1').id, + name="Physical" + )) + product_product_8 = self.env['product.product'].create(dict( + name="iMac", + categ_id=product_category_5.id, + standard_price=1299.0, + list_price=1799.0, + type="consu", + uom_id=self.env.ref('product.product_uom_unit').id, + uom_po_id=self.env.ref('product.product_uom_unit').id, + default_code="E-COM09", + weight="9.54" + )) + product_1 = product_product_8 + product_attribute_1 = self.env['product.attribute'].create(dict( + name="Memory" + )) + product_attribute_value_1 = self.env['product.attribute.value'].create(dict( + name="16 GB", + attribute_id=product_attribute_1.id + )) + product_product_11 = self.env['product.product'].create(dict( + name="iPod", + categ_id=product_category_5.id, + standard_price=14, + list_price=16.50, + type="consu", + uom_id=self.env.ref('product.product_uom_unit').id, + uom_po_id=self.env.ref('product.product_uom_unit').id, + default_code="E-COM12", + attribute_value_ids=[(6,0,[product_attribute_value_1.id])] + )) + product_2 = product_product_11 # In order to test I create sales order and confirmed it. order = self.env['sale.order'].create({ @@ -45,7 +102,20 @@ def test_sale_to_invoice_and_to_be_invoiced(self): order.with_context(context).action_confirm() # Now I create invoice. - advance_product = self.env.ref('sale.advance_product_0') + advance_product_0 = self.env['product.product'].create(dict( + name="Deposit", + categ_id=self.env.ref('product.product_category_1').id, + type="service", + list_price=150.0, + invoice_policy="order", + standard_price=100.0, + uom_id=self.env.ref('product.product_uom_unit').id, + uom_po_id=self.env.ref('product.product_uom_unit').id, + company_id=[], + taxes_id=[], + supplier_taxes_id=[] + )) + advance_product = advance_product_0 advance_product.property_account_income_id = self.env['account.account'].search( [('user_type_id', '=', self.env.ref('account.data_account_type_revenue').id)], limit=1) @@ -142,7 +212,7 @@ def test_amount_delivered_and_ordered_qty(self): 'taxes_id': False, # force no tax }) - partner = self.env.ref('base.res_partner_1') + partner = self.res_partner_1 partner.property_account_receivable_id = self.env['account.account'].search([('user_type_id', '=', self.env.ref('account.data_account_type_revenue').id)], limit=1) # create Sales order, with 2 lines: one delivered, one ordered diff --git a/addons/sale_stock/tests/test_sale_stock.py b/addons/sale_stock/tests/test_sale_stock.py index 1081e18f153d7d..f7681924e80cff 100644 --- a/addons/sale_stock/tests/test_sale_stock.py +++ b/addons/sale_stock/tests/test_sale_stock.py @@ -87,10 +87,23 @@ def test_01_sale_stock_order(self): self.assertFalse(self.so.order_line[0].product_updatable) self.assertTrue(self.so.picking_ids, 'Sale Stock: no picking created for "invoice on order" stockable products') # let's do an invoice for a deposit of 5% + advance_product_0 = self.env['product.product'].create(dict( + name="Deposit", + categ_id=self.env.ref('product.product_category_1').id, + type="service", + list_price=150.0, + invoice_policy="order", + standard_price=100.0, + uom_id=self.env.ref('product.product_uom_unit').id, + uom_po_id=self.env.ref('product.product_uom_unit').id, + company_id=[], + taxes_id=[], + supplier_taxes_id=[] + )) adv_wiz = self.env['sale.advance.payment.inv'].with_context(active_ids=[self.so.id]).create({ 'advance_payment_method': 'percentage', 'amount': 5.0, - 'product_id': self.env.ref('sale.advance_product_0').id, + 'product_id': advance_product_0.id, }) act = adv_wiz.with_context(open_invoices=True).create_invoices() inv = self.env['account.invoice'].browse(act['res_id']) @@ -118,8 +131,44 @@ def test_02_sale_stock_return(self): of the picking. Check that a refund invoice is well generated. """ # intial so - self.partner = self.env.ref('base.res_partner_1') - self.product = self.env.ref('product.product_delivery_01') + res_partner_category_13 = self.env['res.partner.category'].create(dict( + name="Distributor", + color=9 + )) + res_partner_category_12 = self.env['res.partner.category'].create(dict( + name="Office Supplies", + color=8 + )) + res_partner_1 = self.env['res.partner'].create(dict( + name="ASUSTeK", + category_id=[(6, 0, [res_partner_category_13.id, res_partner_category_12.id])], + supplier=True, + customer=False, + is_company=True, + city="Taipei", + zip="106", + country_id=self.env.ref('base.tw').id, + street="1 Hong Kong street", + email="asusteK@yourcompany.example.com", + phone="(+886) (02) 4162 2023", + website="http://www.asustek.com" + )) + self.partner = res_partner_1 + product_category_5 = self.env['product.category'].create(dict( + parent_id=self.env.ref('product.product_category_1').id, + name="Physical" + )) + product_delivery_01 = self.env['product.product'].create(dict( + name="Switch, 24 ports", + categ_id=product_category_5.id, + standard_price=55.0, + list_price=70.0, + type="consu", + uom_id=self.env.ref('product.product_uom_unit').id, + uom_po_id=self.env.ref('product.product_uom_unit').id, + default_code="PROD_DEL" + )) + self.product = product_delivery_01 so_vals = { 'partner_id': self.partner.id, 'partner_invoice_id': self.partner.id, @@ -192,8 +241,44 @@ def test_03_sale_stock_delivery_partial(self): the SO is set on 'done', the SO should be fully invoiced. """ # intial so - self.partner = self.env.ref('base.res_partner_1') - self.product = self.env.ref('product.product_delivery_01') + res_partner_category_13 = self.env['res.partner.category'].create(dict( + name="Distributor", + color=9 + )) + res_partner_category_12 = self.env['res.partner.category'].create(dict( + name="Office Supplies", + color=8 + )) + res_partner_1 = self.env['res.partner'].create(dict( + name="ASUSTeK", + category_id=[(6, 0, [res_partner_category_13.id, res_partner_category_12.id])], + supplier=True, + customer=False, + is_company=True, + city="Taipei", + zip="106", + country_id=self.env.ref('base.tw').id, + street="1 Hong Kong street", + email="asusteK@yourcompany.example.com", + phone="(+886) (02) 4162 2023", + website="http://www.asustek.com" + )) + self.partner = res_partner_1 + product_category_5 = self.env['product.category'].create(dict( + parent_id=self.env.ref('product.product_category_1').id, + name="Physical" + )) + product_delivery_01 = self.env['product.product'].create(dict( + name="Switch, 24 ports", + categ_id=product_category_5.id, + standard_price=55.0, + list_price=70.0, + type="consu", + uom_id=self.env.ref('product.product_uom_unit').id, + uom_po_id=self.env.ref('product.product_uom_unit').id, + default_code="PROD_DEL" + )) + self.product = product_delivery_01 so_vals = { 'partner_id': self.partner.id, 'partner_invoice_id': self.partner.id, @@ -341,7 +426,33 @@ def test_05_confirm_cancel_confirm(self): """ item1 = self.products['prod_order'] partner1 = self.partner.id - partner2 = self.env.ref('base.res_partner_2').id + res_partner_category_0 = self.env['res.partner.category'].create(dict( + name="Partner", + color=1, + )) + res_partner_category_7 = self.env['res.partner.category'].create(dict( + name="IT Services", + color=5, + parent_id=res_partner_category_0.id + )) + res_partner_category_9 = self.env['res.partner.category'].create(dict( + name="Components Buyer", + color=6 + )) + res_partner_2 = self.env['res.partner'].create(dict( + name="Agrolait", + category_id=[(6, 0, [res_partner_category_7.id, res_partner_category_9.id])], + is_company=True, + city="Wavre", + zip="1300", + country_id=self.env.ref('base.be').id, + street="69 rue de Namur", + email="agrolait@yourcompany.example.com", + phone="+32 10 588 558", + website="http://www.agrolait.com", + property_payment_term_id=self.env.ref('account.account_payment_term_net').id + )) + partner2 = res_partner_2 so1 = self.env['sale.order'].create({ 'partner_id': partner1, 'order_line': [(0, 0, { diff --git a/addons/web/controllers/main.py b/addons/web/controllers/main.py index c65c4eac7de023..98cf45fb61aa80 100644 --- a/addons/web/controllers/main.py +++ b/addons/web/controllers/main.py @@ -97,9 +97,8 @@ def redirect_with_hash(*args, **kw): return http.redirect_with_hash(*args, **kw) def abort_and_redirect(url): - r = request.httprequest response = werkzeug.utils.redirect(url, 302) - response = r.app.get_response(r, response, explicit_session=False) + response = http.root.get_response(request.httprequest, response, explicit_session=False) werkzeug.exceptions.abort(response) def ensure_db(redirect='/web/database/selector'): @@ -434,6 +433,12 @@ def binary_content(xmlid=None, model='ir.attachment', id=None, field='datas', un #---------------------------------------------------------- # Odoo Web web Controllers #---------------------------------------------------------- + +# Shared parameters for all login/signup flows +SIGN_UP_REQUEST_PARAMS = {'db', 'login', 'debug', 'token', 'message', 'error', 'scope', 'mode', + 'redirect', 'redirect_hostname', 'email', 'name', 'partner_id', + 'password', 'confirm_password', 'city', 'country_id', 'lang'} + class Home(http.Controller): @http.route('/', type='http', auth="none") @@ -476,7 +481,7 @@ def web_login(self, redirect=None, **kw): if not request.uid: request.uid = odoo.SUPERUSER_ID - values = request.params.copy() + values = {k: v for k, v in request.params.items() if k in SIGN_UP_REQUEST_PARAMS} try: values['databases'] = http.db_list() except odoo.exceptions.AccessDenied: @@ -654,7 +659,7 @@ def post(self, path): from werkzeug.wrappers import BaseResponse base_url = request.httprequest.base_url query_string = request.httprequest.query_string - client = Client(request.httprequest.app, BaseResponse) + client = Client(http.root, BaseResponse) headers = {'X-Openerp-Session-Id': request.session.sid} return client.post('/' + path, base_url=base_url, query_string=query_string, headers=headers, data=data) diff --git a/addons/web/static/src/js/fields/basic_fields.js b/addons/web/static/src/js/fields/basic_fields.js index 97b1ee36a9e7bc..1469ae514bac19 100644 --- a/addons/web/static/src/js/fields/basic_fields.js +++ b/addons/web/static/src/js/fields/basic_fields.js @@ -1295,22 +1295,13 @@ var FieldBinaryFile = AbstractFieldBinary.extend({ this.filename_value = this.recordData[this.attrs.filename]; }, _renderReadonly: function () { - this.do_toggle(!!this.value); - if (this.value) { - this.$el.empty().append($("").addClass('fa fa-download')); - if (this.recordData.id) { - this.$el.css('cursor', 'pointer'); - } else { - this.$el.css('cursor', 'not-allowed'); - } - if (this.filename_value) { - this.$el.append(" " + this.filename_value); - } - } - if (!this.res_id) { - this.$el.css('cursor', 'not-allowed'); - } else { - this.$el.css('cursor', 'pointer'); + var visible = !!(this.value && this.res_id); + this.$el.empty().css('cursor', 'not-allowed'); + this.do_toggle(visible); + if (visible) { + this.$el.css('cursor', 'pointer') + .text(this.filename_value || '') + .prepend($(''), ' '); } }, _renderEdit: function () { diff --git a/addons/web/static/tests/fields/basic_fields_tests.js b/addons/web/static/tests/fields/basic_fields_tests.js index c0ba0353c491d5..9cffc2ea70b0dc 100644 --- a/addons/web/static/tests/fields/basic_fields_tests.js +++ b/addons/web/static/tests/fields/basic_fields_tests.js @@ -1512,8 +1512,7 @@ QUnit.module('basic_fields', { }); QUnit.test('binary fields that are readonly in create mode do not download', function (assert) { - assert.expect(2); - + assert.expect(4); // save the session function var oldGetFile = session.get_file; session.get_file = function (option) { @@ -1546,10 +1545,17 @@ QUnit.module('basic_fields', { form.$('.o_field_many2one input').click(); $dropdown.find('li:not(.o_m2o_dropdown_option):contains(xphone)').click(); - assert.strictEqual(form.$('a.o_field_widget[name="document"] > .fa-download').length, 1, + assert.containsOnce(form, 'a.o_field_widget[name="document"]', 'The link to download the binary should be present'); + assert.containsNone(form, 'a.o_field_widget[name="document"] > .fa-download', + 'The download icon should not be present'); - form.$('a.o_field_widget[name="document"]').click(); + var link = form.$('a.o_field_widget[name="document"]'); + assert.ok(link.is(':hidden'), "the link element should not be visible"); + + // force visibility to test that the clicking has also been disabled + link.removeClass('o_hidden'); + testUtils.dom.click(link); assert.verifySteps([]); // We shoudln't have passed through steps diff --git a/addons/website/models/website.py b/addons/website/models/website.py index cbaf967fb42806..568867d6f8e780 100644 --- a/addons/website/models/website.py +++ b/addons/website/models/website.py @@ -9,7 +9,7 @@ from werkzeug import urls from werkzeug.exceptions import NotFound -from odoo import api, fields, models, tools +from odoo import api, fields, models, tools, http from odoo.addons.http_routing.models.ir_http import slugify, _guess_mimetype from odoo.addons.website.models.ir_http import sitemap_qs2dom from odoo.addons.portal.controllers.portal import pager @@ -356,7 +356,7 @@ def get_url_localized(router, lang): arguments[key] = val.with_context(lang=lang) return router.build(request.endpoint, arguments) - router = request.httprequest.app.get_db_router(request.db).bind('') + router = http.root.get_db_router(request.db).bind('') for code, dummy in self.get_languages(): lg_path = ('/' + code) if code != default else '' lg_codes = code.split('_') @@ -466,7 +466,7 @@ def enumerate_pages(self, query_string=None, force=False): :rtype: list({name: str, url: str}) """ - router = request.httprequest.app.get_db_router(request.db) + router = http.root.get_db_router(request.db) # Force enumeration to be performed as public user url_set = set() diff --git a/addons/website/static/src/js/content/snippets.animation.js b/addons/website/static/src/js/content/snippets.animation.js index cded40215bea90..22ddcb07a9f9c7 100644 --- a/addons/website/static/src/js/content/snippets.animation.js +++ b/addons/website/static/src/js/content/snippets.animation.js @@ -595,7 +595,10 @@ registry.mediaVideo = Animation.extend({ var def = this._super.apply(this, arguments); if (this.$target.children('iframe').length) { - // There already is an