-
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.
Merge pull request #6 from laslabs/feature/9.0/LABS-265_pharmacy_address
[9.0][ADD] Store and Organization Handling
- Loading branch information
Showing
39 changed files
with
853 additions
and
195 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 was deleted.
Oops, something went wrong.
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,113 @@ | ||
# -*- 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 CarepointCarepointAddressStore(models.Model): | ||
""" Binding Model for the Carepoint Address Store """ | ||
_name = 'carepoint.carepoint.address.store' | ||
_inherit = 'carepoint.binding' | ||
_inherits = {'carepoint.address.store': 'odoo_id'} | ||
_description = 'Carepoint Address Store Many2Many Rel' | ||
_cp_lib = 'store_address' # Name of model in Carepoint lib (snake_case) | ||
|
||
odoo_id = fields.Many2one( | ||
comodel_name='carepoint.address.store', | ||
string='Company', | ||
required=True, | ||
ondelete='cascade' | ||
) | ||
|
||
|
||
class CarepointAddressStore(models.Model): | ||
""" Adds the ``One2many`` relation to the Carepoint bindings | ||
(``carepoint_bind_ids``) | ||
""" | ||
_name = 'carepoint.address.store' | ||
_inherit = 'carepoint.address.abstract' | ||
_description = 'Carepoint Address Store' | ||
|
||
carepoint_bind_ids = fields.One2many( | ||
comodel_name='carepoint.carepoint.address.store', | ||
inverse_name='odoo_id', | ||
string='Carepoint Bindings', | ||
) | ||
|
||
|
||
@carepoint | ||
class CarepointAddressStoreAdapter(CarepointCRUDAdapter): | ||
""" Backend Adapter for the Carepoint Address Store """ | ||
_model_name = 'carepoint.carepoint.address.store' | ||
|
||
|
||
@carepoint | ||
class CarepointAddressStoreBatchImporter(DelayedBatchImporter): | ||
""" Import the Carepoint Address Stores. | ||
For every address in the list, a delayed job is created. | ||
""" | ||
_model_name = ['carepoint.carepoint.address.store'] | ||
|
||
|
||
@carepoint | ||
class CarepointAddressStoreImportMapper( | ||
CarepointAddressAbstractImportMapper, | ||
): | ||
_model_name = 'carepoint.carepoint.address.store' | ||
|
||
@mapping | ||
@only_create | ||
def partner_id(self, record): | ||
""" It returns either the commercial partner or parent & defaults """ | ||
binder = self.binder_for('carepoint.carepoint.store') | ||
store_id = binder.to_odoo(record['store_id'], browse=True) | ||
_sup = super(CarepointAddressStoreImportMapper, self) | ||
return _sup.partner_id( | ||
record, store_id, | ||
) | ||
|
||
@mapping | ||
def carepoint_id(self, record): | ||
return {'carepoint_id': '%d,%d' % (record['store_id'], | ||
record['addr_id'])} | ||
|
||
|
||
@carepoint | ||
class CarepointAddressStoreImporter( | ||
CarepointAddressAbstractImporter, | ||
): | ||
_model_name = ['carepoint.carepoint.address.store'] | ||
_base_mapper = CarepointAddressStoreImportMapper | ||
|
||
def _import_dependencies(self): | ||
""" Import depends for record """ | ||
super(CarepointAddressStoreImporter, self)._import_dependencies() | ||
self._import_dependency(self.carepoint_record['store_id'], | ||
'carepoint.carepoint.store') | ||
|
||
|
||
@carepoint | ||
class CarepointAddressStoreUnit(ConnectorUnit): | ||
_model_name = 'carepoint.carepoint.address.store' | ||
|
||
def _import_addresses(self, store_id, partner_binding): | ||
adapter = self.unit_for(CarepointCRUDAdapter) | ||
importer = self.unit_for(CarepointAddressStoreImporter) | ||
address_ids = adapter.search(store_id=store_id) | ||
for address_id in address_ids: | ||
importer.run(address_id) |
Oops, something went wrong.