Skip to content

Commit 4cf181b

Browse files
committed
[IMP] check for existing fields
1 parent 55847f4 commit 4cf181b

File tree

5 files changed

+25
-10
lines changed

5 files changed

+25
-10
lines changed

requirements.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
odoo-client-lib==1.2.2
2-
locust==2.24.0
2+
locust==2.29.1
33
names==0.3.0

setup.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
from setuptools import setup, find_packages
3333

3434
setup(name='OdooLocust',
35-
version='1.6.4',
35+
version='1.6.5',
3636
description='Easily load test Odoo using Locust and odoolib.',
3737
author='Nicolas Seinlet',
3838
author_email='',
@@ -41,7 +41,7 @@
4141
package_dir={'': 'src'},
4242
install_requires=[
4343
'odoo-client-lib>=1.2.2',
44-
'locust>=2.24.0',
44+
'locust>=2.29.1',
4545
'names>=0.3.0',
4646
],
4747
long_description="See the home page for any information: https://github.com/odoo/OdooLocust.",

src/OdooLocust/OdooTaskSet.py

+4
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,10 @@ def _action_load(self, action_id, action_type=None):
6565
base_action = self.client.get_model('ir.actions.actions').read(action_id, ['type'])
6666
action_type = base_action[0]['type']
6767
return self.client.get_model(action_type).read(action_id, [])
68+
69+
def _check_fields(self, model, fields_list):
70+
all_fields = self.client.get_model(model).fields_get()
71+
return [ f for f in fields_list if f in all_fields.keys() ]
6872

6973

7074
class OdooGenericTaskSet(OdooTaskSet):

src/OdooLocust/crm/lead.py

+15-5
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,16 @@ class CrmLead(OdooTaskSet):
3838
list_fields = ["stage_id", "active", "company_id", "calendar_event_count", "company_id", "user_company_ids", "date_deadline", "create_date", "name", "contact_name", "partner_name", "email_from", "phone", "city", "state_id", "country_id", "partner_id", "user_id", "team_id", "active", "campaign_id", "referred", "medium_id", "probability", "source_id", "message_needaction", "tag_ids", "priority"]
3939
form_fields = ["stage_id", "active", "company_id", "calendar_event_count", "sale_amount_total", "sale_order_count", "visitor_page_count", "duplicate_lead_count", "name", "company_currency", "expected_revenue", "recurring_revenue", "recurring_plan", "automated_probability", "is_automated_probability", "probability", "is_partner_visible", "partner_id", "partner_name", "street", "street2", "city", "state_id", "zip", "country_id", "website", "lang_active_count", "lang_code", "lang_id", "is_blacklisted", "partner_is_blacklisted", "phone_blacklisted", "mobile_blacklisted", "email_state", "phone_state", "partner_email_update", "partner_phone_update", "email_from", "phone", "lost_reason_id", "date_conversion", "user_company_ids", "contact_name", "title", "function", "mobile", "type", "user_id", "date_deadline", "priority", "tag_ids", "team_id", "lead_properties", "description", "campaign_id", "medium_id", "source_id", "referred", "date_open", "date_closed", "day_open", "day_close", "display_name"]
4040
random_id = -1
41+
_model_id = -1
42+
43+
@property
44+
def model_id(self):
45+
if self._model_id < 0:
46+
irm = self.client.get_model('ir.model.data')
47+
irm_id = irm.search_read([('model', '=', 'crm'), ('name', '=', 'model_crm_lead')], ['res_id'])
48+
if irm_id:
49+
self._model_id = irm_id[0]['res_id']
50+
return self._model_id
4151

4252
def on_start(self):
4353
super().on_start()
@@ -57,7 +67,8 @@ def test_searchread(self):
5767
limit=80,
5868
context=self.client.get_user_context()
5969
)
60-
self.random_id = res[0]['id']
70+
if res:
71+
self.random_id = res[0]['id']
6172

6273
@task(5)
6374
def test_websearchread(self):
@@ -68,7 +79,8 @@ def test_websearchread(self):
6879
limit=80,
6980
context=self.client.get_user_context()
7081
)
71-
self.random_id = res[0]['id']
82+
if res:
83+
self.random_id = res[0]['id']
7284

7385
@task(20)
7486
def test_read(self):
@@ -89,16 +101,14 @@ def lead_stage_change(self):
89101

90102
@task(5)
91103
def test_activity(self):
92-
model_model = self.client.get_model('ir.model')
93-
crm_lead_model_id = model_model.search([('model', '=', 'crm.lead')], limit=1, context=self.client.get_user_context())
94104
activity_model = self.client.get_model('mail.activity')
95105
res = activity_model.create({
96106
"activity_type_id": 4,
97107
"calendar_event_id": False,
98108
"date_deadline": (date(2012, 1 ,1)+timedelta(days=random.randint(1,3650))).isoformat(),
99109
"note": False,
100110
"res_id": self.random_id,
101-
"res_model_id": crm_lead_model_id[0],
111+
"res_model_id": self.model_id,
102112
"summary": "Todo",
103113
"user_id": self.client.user_id,
104114
}, context=self.client.get_user_context())

src/OdooLocust/crm/quotation.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434

3535
class SaleOrder(OdooTaskSet):
3636
list_fields = ["activity_exception_decoration", "activity_exception_icon", "activity_state", "activity_summary", "activity_type_icon", "activity_type_id", "name", "create_date", "commitment_date", "expected_date", "partner_id", "website_id", "user_id", "activity_ids", "team_id", "tag_ids", "company_id", "amount_untaxed", "amount_tax", "amount_total", "state", "validity_date", "invoice_status", "message_needaction", "currency_id"]
37-
form_fields = ["authorized_transaction_ids", "is_subscription", "enterprise_is_new_plan", "state", "subscription_management", "is_upselling", "stage_category", "end_date", "archived_product_count", "partner_credit_warning", "project_ids", "is_product_milestone", "project_count", "milestone_count", "tasks_count", "timesheet_count", "timesheet_total_duration", "timesheet_encode_uom_id", "expense_count", "delivery_count", "id", "planning_first_sale_line_id", "planning_initial_date", "planning_hours_to_plan", "planning_hours_planned", "invoice_count", "attendee_count", "event_booth_count", "history_count", "recurring_monthly", "mrp_production_count", "database_count", "payment_exception", "to_renew", "renew_state", "name", "partner_id", "commission_plan_frozen", "referrer_id", "commission_plan_id", "delivery_set", "is_all_service", "recompute_delivery_price", "sale_order_template_id", "validity_date", "date_order", "recurrence_id", "invoice_date_diff", "next_invoice_date", "expected_next_invoice_date", "show_update_pricelist", "pricelist_id", "company_id", "currency_id", "tax_country_id", "payment_term_id", "new_sub_id", "old_sub_id", "order_line", "is_avatax", "note", "tax_totals", "commission", "sale_order_option_ids", "user_id", "team_id", "website_id", "is_abandoned_cart", "cart_recovery_email_sent", "require_signature", "require_payment", "website_description", "reference", "client_order_ref", "tag_ids", "start_date", "first_contract_date", "avatax_unique_code", "show_update_fpos", "fiscal_position_id", "partner_invoice_id", "analytic_account_id", "visible_project", "project_id", "invoice_status", "commercial_partner_id", "payment_token_id", "warehouse_id", "picking_policy", "commitment_date", "expected_date", "show_json_popover", "json_popover", "effective_date", "delivery_status", "origin", "campaign_id", "medium_id", "source_id", "internal_note", "enterprise_final_customer_id", "enterprise_security_email", "is_staff_restricted", "subscription_tag_ids", "enterprise_saas", "upsell_order_id", "upsell_date", "upsell_content", "maintenance_subscription_id", "maintenance_main_subscription_id", "maintenance_is_activated", "maintenance_stage_category", "odoo_sh_extra_gb", "odoo_sh_extra_stagings", "odoo_sh_extra_workers", "odoo_sh_extra_dedicated", "exclude_dashboard", "github_user_ids", "is_taxcloud", "is_taxcloud_configured", "display_name"]
37+
form_fields = ["authorized_transaction_ids", "enterprise_is_new_plan", "state", "subscription_management", "is_upselling", "stage_category", "end_date", "archived_product_count", "partner_credit_warning", "project_ids", "is_product_milestone", "project_count", "milestone_count", "tasks_count", "timesheet_count", "timesheet_total_duration", "timesheet_encode_uom_id", "expense_count", "delivery_count", "id", "planning_first_sale_line_id", "planning_initial_date", "planning_hours_to_plan", "planning_hours_planned", "invoice_count", "attendee_count", "event_booth_count", "history_count", "recurring_monthly", "mrp_production_count", "database_count", "payment_exception", "to_renew", "renew_state", "name", "partner_id", "commission_plan_frozen", "referrer_id", "commission_plan_id", "delivery_set", "is_all_service", "recompute_delivery_price", "sale_order_template_id", "validity_date", "date_order", "recurrence_id", "invoice_date_diff", "next_invoice_date", "expected_next_invoice_date", "show_update_pricelist", "pricelist_id", "company_id", "currency_id", "tax_country_id", "payment_term_id", "new_sub_id", "old_sub_id", "order_line", "is_avatax", "note", "tax_totals", "commission", "sale_order_option_ids", "user_id", "team_id", "website_id", "is_abandoned_cart", "cart_recovery_email_sent", "require_signature", "require_payment", "website_description", "reference", "client_order_ref", "tag_ids", "start_date", "first_contract_date", "avatax_unique_code", "show_update_fpos", "fiscal_position_id", "partner_invoice_id", "analytic_account_id", "visible_project", "project_id", "invoice_status", "commercial_partner_id", "payment_token_id", "warehouse_id", "picking_policy", "commitment_date", "expected_date", "show_json_popover", "json_popover", "effective_date", "delivery_status", "origin", "campaign_id", "medium_id", "source_id", "internal_note", "enterprise_final_customer_id", "enterprise_security_email", "is_staff_restricted", "subscription_tag_ids", "enterprise_saas", "upsell_order_id", "upsell_date", "upsell_content", "maintenance_subscription_id", "maintenance_main_subscription_id", "maintenance_is_activated", "maintenance_stage_category", "odoo_sh_extra_gb", "odoo_sh_extra_stagings", "odoo_sh_extra_workers", "odoo_sh_extra_dedicated", "exclude_dashboard", "github_user_ids", "is_taxcloud", "is_taxcloud_configured", "display_name"]
3838
line_fields = ["analytic_precision", "sequence", "display_type", "product_uom_category_id", "product_type", "product_updatable", "product_id", "product_template_id", "product_template_attribute_value_ids", "product_custom_attribute_value_ids", "product_no_variant_attribute_value_ids", "is_configurable_product", "event_id", "event_ticket_id", "is_event_booth", "event_booth_category_id", "event_booth_pending_ids", "name", "temporal_type", "website_description", "analytic_distribution", "product_uom_qty", "qty_delivered", "virtual_available_at_date", "qty_available_today", "free_qty_today", "scheduled_date", "forecast_expected_date", "warehouse_id", "move_ids", "qty_to_deliver", "is_mto", "display_qty_widget", "qty_delivered_method", "qty_invoiced", "qty_to_invoice", "product_uom_readonly", "product_uom", "customer_lead", "recompute_delivery_price", "is_delivery", "price_unit", "tax_id", "price_tax", "discount", "is_downpayment", "price_subtotal", "state", "invoice_status", "currency_id", "company_id", "database_id", "computation"]
3939
random_id = 2795659
4040

@@ -76,7 +76,8 @@ def test_set_to_quotation(self):
7676
def test_quotation_confirm(self):
7777
saleorder_model = self.client.get_model('sale.order')
7878
res = saleorder_model.search([['state', '=', 'draft'], '!', [ 'order_line.product_id.active', '=', False ], [ 'partner_id.country_id', '!=', False], [ 'company_id', '=', 1]], context=self.client.get_user_context())
79-
saleorder_model.action_confirm(random.choice(res), context=self.client.get_user_context())
79+
if res:
80+
saleorder_model.action_confirm(random.choice(res), context=self.client.get_user_context())
8081

8182
@task
8283
def test_quotation_sendemail(self):

0 commit comments

Comments
 (0)