-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[IMP] connector_carepoint: Improved pharmacy handling
* Prefer CarepointStore namespace to MedicalPharmacy in order to allow for cssorg * Bump version, previous versions of stores incompatible * Implement csorg as carepoint_organization
- Loading branch information
Showing
38 changed files
with
655 additions
and
131 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
# -*- coding: utf-8 -*- | ||
# Copyright 2015-2016 LasLabs Inc. | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). | ||
|
||
import logging | ||
from openerp import models, fields | ||
from openerp.addons.connector.connector import ConnectorUnit | ||
from openerp.addons.connector.unit.mapper import (mapping, | ||
only_create, | ||
) | ||
from ..unit.backend_adapter import CarepointCRUDAdapter | ||
from ..backend import carepoint | ||
from ..unit.import_synchronizer import DelayedBatchImporter | ||
|
||
from .address_abstract import (CarepointAddressAbstractImportMapper, | ||
CarepointAddressAbstractImporter, | ||
) | ||
|
||
_logger = logging.getLogger(__name__) | ||
|
||
|
||
class CarepointCarepointAddressOrganization(models.Model): | ||
""" Binding Model for the Carepoint Address Organization """ | ||
_name = 'carepoint.carepoint.address.organization' | ||
_inherit = 'carepoint.binding' | ||
_inherits = {'carepoint.address.organization': 'odoo_id'} | ||
_description = 'Carepoint Address Organization Many2Many Rel' | ||
_cp_lib = 'pharmacy_address' | ||
|
||
odoo_id = fields.Many2one( | ||
comodel_name='carepoint.address.organization', | ||
string='Company', | ||
required=True, | ||
ondelete='cascade' | ||
) | ||
|
||
|
||
class CarepointAddressOrganization(models.Model): | ||
""" Adds the ``One2many`` relation to the Carepoint bindings | ||
(``carepoint_bind_ids``) | ||
""" | ||
_name = 'carepoint.address.organization' | ||
_inherit = 'carepoint.address.abstract' | ||
_description = 'Carepoint Address Organization' | ||
|
||
carepoint_bind_ids = fields.One2many( | ||
comodel_name='carepoint.carepoint.address.organization', | ||
inverse_name='odoo_id', | ||
string='Carepoint Bindings', | ||
) | ||
|
||
|
||
@carepoint | ||
class CarepointAddressOrganizationAdapter(CarepointCRUDAdapter): | ||
""" Backend Adapter for the Carepoint Address Organization """ | ||
_model_name = 'carepoint.carepoint.address.organization' | ||
|
||
|
||
@carepoint | ||
class CarepointAddressOrganizationBatchImporter(DelayedBatchImporter): | ||
""" Import the Carepoint Address Organizations. | ||
For every address in the list, a delayed job is created. | ||
""" | ||
_model_name = ['carepoint.carepoint.address.organization'] | ||
|
||
|
||
@carepoint | ||
class CarepointAddressOrganizationImportMapper( | ||
CarepointAddressAbstractImportMapper, | ||
): | ||
_model_name = 'carepoint.carepoint.address.organization' | ||
|
||
@mapping | ||
@only_create | ||
def partner_id(self, record): | ||
""" It returns either the commercial partner or parent & defaults """ | ||
binder = self.binder_for('carepoint.medical.organization') | ||
organization_id = binder.to_odoo(record['org_id'], browse=True) | ||
_sup = super(CarepointAddressOrganizationImportMapper, self) | ||
return _sup.partner_id( | ||
record, organization_id, | ||
) | ||
|
||
@mapping | ||
def carepoint_id(self, record): | ||
return {'carepoint_id': '%d,%d' % (record['org_id'], | ||
record['addr_id'])} | ||
|
||
|
||
@carepoint | ||
class CarepointAddressOrganizationImporter( | ||
CarepointAddressAbstractImporter, | ||
): | ||
_model_name = ['carepoint.carepoint.address.organization'] | ||
_base_mapper = CarepointAddressOrganizationImportMapper | ||
|
||
def _import_dependencies(self): | ||
""" Import depends for record """ | ||
super( | ||
CarepointAddressOrganizationImporter, self | ||
)._import_dependencies() | ||
self._import_dependency(self.carepoint_record['org_id'], | ||
'carepoint.medical.organization') | ||
|
||
|
||
@carepoint | ||
class CarepointAddressOrganizationUnit(ConnectorUnit): | ||
_model_name = 'carepoint.carepoint.address.organization' | ||
|
||
def _import_addresses(self, organization_id, partner_binding): | ||
adapter = self.unit_for(CarepointCRUDAdapter) | ||
importer = self.unit_for(CarepointAddressOrganizationImporter) | ||
address_ids = adapter.search(org_id=organization_id) | ||
for address_id in address_ids: | ||
importer.run(address_id) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.