Esempio n. 1
0
 def button_confirm(self):
     restricted_partners = self.mapped('partner_id.commercial_partner_id'). \
         filtered(lambda p: p.supplier_state != 'approved'). \
         mapped('display_name')
     if restricted_partners:
         raise WarningOdoo(_("The supplier ​%s has to be approved"
                             " in order to confirm this purchase order.") % (",".join(restricted_partners,)))
     return super().button_confirm()
 def action_confirm(self):
     restricted_partners = self.mapped('partner_id.commercial_partner_id'). \
         filtered(lambda p: p.customer_state != 'approved'). \
         mapped('display_name')
     if restricted_partners:
         raise WarningOdoo(_("The client ​%s has to be approved"
                             " in order to confirm this sale order.") % (",".join(restricted_partners)))
     return super().action_confirm()
Esempio n. 3
0
 def _check_customer_approved_state(self):
     restricted_partners = (self.mapped("partner_id.commercial_partner_id").
                            filtered(lambda p: p.customer_state !=
                                     "approved").mapped("display_name"))
     if restricted_partners:
         raise WarningOdoo(
             _("The client ​%s has to be approved"
               " in order to confirm this sale order.") %
             (",".join(restricted_partners)))
    def button_validate(self):
        outgoings = self.filtered(lambda sp:
                                  (sp.picking_type_code == 'outgoing' and sp.
                                   location_dest_id.usage == 'customer'))
        if outgoings:
            restricted_partners = self.mapped('partner_id.commercial_partner_id'). \
                filtered(lambda p: p.customer_state != 'approved'). \
                mapped('display_name')

            if restricted_partners:
                raise WarningOdoo(
                    _("The partner %s has to be approved in order"
                      " to confirm this stock move.") %
                    (",".join(restricted_partners)))
        return super().button_validate()
    def _check_customer_approved_state(self):
        outgoings = self.filtered(lambda sp:
                                  (sp.picking_type_code == "outgoing" and sp.
                                   location_dest_id.usage == "customer"))
        if outgoings:
            restricted_partners = (
                self.mapped("partner_id.commercial_partner_id").filtered(
                    lambda p: p.customer_state != "approved").mapped(
                        "display_name"))

            if restricted_partners:
                raise WarningOdoo(
                    _("The partner %s has to be approved in order"
                      " to confirm this stock move.") %
                    (",".join(restricted_partners)))
    def _check_supplier_restricted_fields(self, vals):
        if not self.env.user.has_group(
                "partner_validation_purchase.group_partner_restricted_field_purchases"
        ):
            restricted_fields = (
                self.env["res.partner.restricted.field"].search([
                    ("apply_on_purchases", "=", True)
                ]).mapped("field_id.name"))
            vals_fields = set(vals.keys())
            final_restricted_fields = list(
                set(restricted_fields).intersection(vals_fields))

            restricted_suppliers = self.filtered(
                lambda p: p.supplier and p.supplier_state == "approved" and
                (p.is_company or not p.parent_id))
            if final_restricted_fields and restricted_suppliers:
                raise WarningOdoo(
                    _("You are not authorized to modify the following fields: %s"
                      " when the partner’s status is approved.") %
                    str(final_restricted_fields))
Esempio n. 7
0
    def write(self, vals):
        if vals.get('customer_state') == 'approved' and \
                self.filtered(lambda p: p.customer and (p.is_company or not p.parent_id)):
            self.check_customer_state_access()
        if not self.env.user.has_group(
                'partner_validation_sale.group_partner_restricted_field_sales'
        ):
            restricted_fields = self.env['res.partner.restricted.field']. \
                search([('apply_on_sales', '=', True)]).mapped('field_id.name')
            vals_fields = set(vals.keys())
            final_restricted_fields = list(
                set(restricted_fields).intersection(vals_fields))

            restricted_customers = self.filtered(
                lambda p: p.customer and p.customer_state == 'approved' and
                (p.is_company or not p.parent_id))
            if final_restricted_fields and restricted_customers:
                raise WarningOdoo(
                    _("You are not authorized to modify the following fields: %s"
                      " when the partner’s status is approved.") %
                    str(final_restricted_fields))

        return super(ResPartner, self).write(vals)
 def _check_supplier_state_access(self):
     if not self.env.user.has_group(
             "partner_validation_purchase.group_partner_restricted_field_purchases"
     ):
         raise WarningOdoo(
             _("Permission to change the state of the partner denied."))
Esempio n. 9
0
 def check_customer_state_access(self):
     if not self.env.user.has_group(
             'partner_validation_sale.group_partner_restricted_field_sales'
     ):
         raise WarningOdoo(
             _("Permission to change the state of the partner denied."))