Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

l10n_fr_chorus_account: Handle companies with parents #10

Open
wants to merge 1 commit into
base: 11-chorus-backport
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion l10n_fr_chorus_account/models/chorus_partner_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class ChorusPartnerService(models.Model):

partner_id = fields.Many2one(
'res.partner', string='Customer', ondelete='cascade',
domain=[('parent_id', '=', False)])
domain=[('is_company', '=', True)])
code = fields.Char(string='Service Code', required=True)
active = fields.Boolean(default=True)
name = fields.Char(string='Service Name')
Expand Down
5 changes: 3 additions & 2 deletions l10n_fr_chorus_account/models/partner.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ def fr_chorus_identifier_get(self):
raise_if_ko = self._context.get('chorus_raise_if_ko', True)
partners = []
for partner in self.filtered(lambda p: not p.fr_chorus_identifier):
if partner.parent_id:
if not partner.is_company:
if raise_if_ko:
raise UserError(_(
"Cannot get Chorus Identifier on a contact (%s)")
Expand Down Expand Up @@ -369,7 +369,7 @@ def fr_chorus_identifier_and_required_button(self):
def chorus_cron(self):
logger.info('Start Chorus partner cron')
to_update_partners = self.search([
('parent_id', '=', False),
('is_company', '=', True),
('customer_invoice_transmit_method_code', '=', 'fr-chorus'),
('siren', '!=', False),
('nic', '!=', False)])
Expand All @@ -381,6 +381,7 @@ def chorus_service_ok(self):
# Method used upon SO or invoice validation
self.ensure_one()
if (
not self.is_company and
self.parent_id and
self.name and
self.fr_chorus_service_id and
Expand Down