How to use _filter_rules method in autotest

Best Python code snippet using autotest_python

account_fiscal_position.py

Source:account_fiscal_position.py Github

copy

Full Screen

...87 string="Regras ISSQN", domain=[('domain', '=', 'issqn')])88 ii_tax_rule_ids = fields.One2many(89 'account.fiscal.position.tax.rule', 'fiscal_position_id',90 string="Regras II", domain=[('domain', '=', 'ii')])91 def _filter_rules(self, fpos_id, type_tax, partner, product, state):92 rule_obj = self.env['account.fiscal.position.tax.rule']93 domain = [('fiscal_position_id', '=', fpos_id),94 ('domain', '=', type_tax)]95 rules = rule_obj.search(domain)96 if rules:97 rules_points = {}98 for rule in rules:99 rules_points[rule.id] = 0100 if rule.tipo_produto == product.fiscal_type:101 rules_points[rule.id] += 1102 if state in rule.state_ids:103 rules_points[rule.id] += 1104 if product.categ_id in rule.product_category_ids:105 rules_points[rule.id] += 1106 if product in rule.product_ids:107 rules_points[rule.id] += 1108 if len(rule.product_ids) > 0:109 rules_points[rule.id] -= 1110 if not rule.tipo_produto:111 rules_points[rule.id] -= 1112 if len(rule.product_category_ids) > 0:113 rules_points[rule.id] -= 1114 if len(rule.state_ids) > 0:115 rules_points[rule.id] -= 1116 greater_rule = max([(v, k) for k, v in rules_points.items()])117 if greater_rule[0] <= 0:118 return {}119 rules = [rules.browse(greater_rule[1])]120 return {121 ('%s_rule_id' % type_tax): rules[0],122 'cfop_id': rules[0].cfop_id,123 ('tax_%s_id' % type_tax): rules[0].tax_id,124 # ICMS125 'icms_cst_normal': rules[0].cst_icms,126 'icms_aliquota_reducao_base': rules[0].reducao_icms,127 'incluir_ipi_base': rules[0].incluir_ipi_base,128 # ICMS ST129 'tax_icms_st_id': rules[0].tax_icms_st_id,130 'icms_st_aliquota_mva': rules[0].aliquota_mva,131 'icms_st_aliquota_reducao_base': rules[0].reducao_icms_st,132 'icms_st_aliquota_deducao': rules[0].icms_st_aliquota_deducao,133 # ICMS Difal134 'tem_difal': rules[0].tem_difal,135 'tax_icms_inter_id': rules[0].tax_icms_inter_id,136 'tax_icms_intra_id': rules[0].tax_icms_intra_id,137 'tax_icms_fcp_id': rules[0].tax_icms_fcp_id,138 # Simples139 'icms_csosn_simples': rules[0].csosn_icms,140 'icms_aliquota_credito': rules[0].icms_aliquota_credito,141 # IPI142 'ipi_cst': rules[0].cst_ipi,143 'ipi_reducao_bc': rules[0].reducao_ipi,144 # PIS145 'pis_cst': rules[0].cst_pis,146 # PIS147 'cofins_cst': rules[0].cst_cofins,148 }149 else:150 return {}151 @api.model152 def map_tax_extra_values(self, company, product, partner):153 to_state = partner.state_id154 res = {}155 vals = self._filter_rules(156 self.id, 'icms', partner, product, to_state)157 res.update({k: v for k, v in vals.items() if v})158 vals = self._filter_rules(159 self.id, 'simples', partner, product, to_state)160 res.update({k: v for k, v in vals.items() if v})161 vals = self._filter_rules(162 self.id, 'ipi', partner, product, to_state)163 res.update({k: v for k, v in vals.items() if v})164 vals = self._filter_rules(165 self.id, 'pis', partner, product, to_state)166 res.update({k: v for k, v in vals.items() if v})167 vals = self._filter_rules(168 self.id, 'cofins', partner, product, to_state)169 res.update({k: v for k, v in vals.items() if v})170 vals = self._filter_rules(171 self.id, 'issqn', partner, product, to_state)172 res.update({k: v for k, v in vals.items() if v})173 vals = self._filter_rules(174 self.id, 'ii', partner, product, to_state)175 res.update({k: v for k, v in vals.items() if v})...

Full Screen

Full Screen

container.py

Source:container.py Github

copy

Full Screen

1class ElementFilterRules:2 __element_sources = {"img": [{"src": True}, {"data-src": True}],3 "video": [{"src": True}, {"poster": True}],4 "embed": [{"src": True}],5 "source": [{"src": True}],6 "audio": [{"src": True}],7 "input": [{"src": True}],8 "object": [{"data": True}, {"codebase": True}],9 "track": [{"src": True}]}10 __stylesheet_link = {"link": [{"href": True, "rel": "stylesheet"}]}11 __js_script = {"script": [{"src": True}]}12 __script = {"script": [None]}13 __style = {"style": [None]}14 __description_style = {True: [{"style": True}]}15 __frames = {"frame": [{"src": True}],16 "iframe": [{"src": True}]}17 __events = ["onafterprint", "onbeforeprint", "onbeforeunload", "onerror",18 "onhashchange", "onload", "onmessage", "onoffline", "ononline",19 "onpagehide", "onpageshow", "onpopstate", "onresize",20 "onstorage", "onunload", "onblur", "onchange", "oncontextmenu",21 "onfocus", "oninput", "oninvalid", "onreset", "onsearch",22 "onselect", "onsubmit", "onkeydown", "onkeypress", "onkeyup",23 "onclick", "ondblclick", "onmousedown", "onmousemove",24 "onmouseout", "onmouseover", "onmouseup", "onmousewheel",25 "onwheel", "ondrag", "ondragend", "ondragenter", "ondragleave",26 "ondragover", "ondragstart", "ondrop", "onscroll", "oncopy",27 "oncut", "onpaste", "onabort", "oncanplay", "oncanplaythrough",28 "oncuechange", "ondurationchange", "onemptied", "onended",29 "onerror", "onloadeddata", "onloadedmetadata", "onloadstart",30 "onpause", "onplay", "onplaying", "onprogress", "onratechange",31 "onseeked", "onseeking", "onstalled", "onsuspend",32 "ontimeupdate", "onvolumechange", "onwaiting", "onshow",33 "ontoggle"]34 @property35 def elements(self):36 return self.__flatten(ElementFilterRules.__element_sources)37 @property38 def stylesheet_link(self):39 return self.__flatten(ElementFilterRules.__stylesheet_link)40 @property41 def js_script(self):42 return self.__flatten(ElementFilterRules.__js_script)43 @property44 def script(self):45 return self.__flatten(ElementFilterRules.__script)46 @property47 def events(self):48 return self.__format_events(ElementFilterRules.__events)49 @property50 def style(self):51 return self.__flatten(ElementFilterRules.__style)52 @property53 def description_style(self):54 return self.__flatten(ElementFilterRules.__description_style)55 @property56 def frames(self):57 return self.__flatten(ElementFilterRules.__frames)58 @staticmethod59 def __flatten(rules):60 flatten_rules = [(element_name, attr_dict) for element_name, attr_list in rules.items()61 for attr_dict in attr_list]62 return flatten_rules63 @staticmethod64 def __format_events(event_list):65 formatted_rules = [(True, {attr_name: True}) for attr_name in event_list]66 return formatted_rules67class HTMLFilter:68 def __init__(self, html_parser):69 self._filter_rules = ElementFilterRules()70 self._parser = html_parser71 @property72 def elements(self):73 return self.__get_element_list_from(self._filter_rules.elements)74 @property75 def stylesheet_link(self):76 return self.__get_element_list_from(self._filter_rules.stylesheet_link)77 @property78 def js_script(self):79 return self.__get_element_list_from(self._filter_rules.js_script)80 @property81 def script(self):82 return self.__get_element_list_from(self._filter_rules.script)83 @property84 def elements_event(self):85 return self.__get_element_list_from(self._filter_rules.events)86 @property87 def style(self):88 return self.__get_element_list_from(self._filter_rules.style)89 @property90 def description_style(self):91 return self.__get_element_list_from(self._filter_rules.description_style)92 @property93 def frames(self):94 return self.__get_element_list_from(self._filter_rules.frames)95 def __get_element_list_from(self, rules):96 element_rules = [(element, attr) for name, attrs in rules97 for element, attr in self.__convert_to_list(name, attrs)]98 return element_rules99 def __convert_to_list(self, name, attrs: dict):100 attr = self.__get_depended_attribute(attrs)101 elements = self._parser.find_elements(name, attrs)102 return [(element, attr) for element in elements]103 @staticmethod104 def __get_depended_attribute(attrs):105 try:106 attr = (attr for attr, value in attrs.items() if value is True).__next__()107 except Exception:108 attr = None109 finally:...

Full Screen

Full Screen

job_options.py

Source:job_options.py Github

copy

Full Screen

...11 else:12 return self.rule.result_tag13 @property14 def tags(self):15 def _filter_rules(tags):16 return [tag for tag in tags if not isinstance(tag, InfernoRule)]17 if self.settings.get('source_tags') is not None:18 tags = _filter_rules(self.settings.get('source_tags'))19 else:20 tags = _filter_rules(self.rule.source_tags)21 # note that all day range options are disabled if we pass tags in22 # on the command line23 count = None24 if self.settings.get('day_start') is not None:25 start = self.settings.get('day_start')26 count = 127 elif self.rule.day_start is not None:28 start = self.rule.day_start29 else:30 start = date.today()31 if self.settings.get('day_offset') is not None:32 start += timedelta(days=-self.settings.get('day_offset'))33 count = 134 else:...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run autotest automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful