Ejemplo n.º 1
0
    def __get_raw_values(payment, field_id):
        """
        Line Single Value for given Field

        :param payment: account.payment
        :param field_id: str
        :return: dict
        """

        from odoo.addons.splashsync.helpers import M2OHelper

        # ==================================================================== #
        # Generic Fields
        if field_id in InvoicePaymentsHelper.__generic_fields:
            return getattr(payment, field_id)
        # ==================================================================== #
        # Payment Method
        if field_id == "journal_code":
            return M2OHelper.get_name(payment, "journal_id", "name")
        if field_id == "journal_type":
            return M2OHelper.get_name(payment, "journal_id", "type")
        if field_id == "journal_name":
            return M2OHelper.get_name(payment, "journal_id")
        # ==================================================================== #
        # Payment Date
        if field_id == "payment_date":
            if isinstance(payment.payment_date, date):
                return payment.payment_date.strftime(const.__SPL_T_DATECAST__)
            else:
                return
        # ==================================================================== #
        # Payment Amount
        if field_id == "amount":
            return float(getattr(payment, field_id))
Ejemplo n.º 2
0
 def getAddressFields(self, index, field_id):
     # ====================================================================#
     # Shipping Address Field Requested
     if field_id.find("__shipping__") < 0:
         return
     self._in.__delitem__(index)
     # ====================================================================#
     # Remove Pattern from Field Id
     real_field_id = field_id.replace("__shipping__", "")
     # ====================================================================#
     # Detect Shipping Address
     try:
         if self.object.partner_shipping_id.id > 0:
             self.Address = self.object.partner_shipping_id[0]
         elif self.object.partner_id.id > 0:
             self.Address = self.object.partner_id[0]
         else:
             self._out[field_id] = None
             return
     except MissingError:
         self._out[field_id] = None
         return
     # ==================================================================== #
     # Non Generic Data
     if real_field_id == "name" and len(self.Address.parent_id) > 0:
         self._out[field_id] = getattr(self.Address.parent_id,
                                       real_field_id)
     elif real_field_id == "contact":
         self._out[field_id] = getattr(
             self.Address,
             "name") if len(self.Address.parent_id) > 0 else ""
     elif real_field_id == "country_code":
         self._out[field_id] = M2OHelper.get_name(self.Address,
                                                  "country_id",
                                                  index="code")
     elif real_field_id == "country_name":
         self._out[field_id] = M2OHelper.get_name(self.Address,
                                                  "country_id")
     elif real_field_id == "state_id":
         self._out[field_id] = M2OHelper.get_name(self.Address,
                                                  "state_id",
                                                  index="code")
     elif real_field_id == "state_name":
         self._out[field_id] = M2OHelper.get_name(self.Address, "state_id")
     # ====================================================================#
     # Parse generic Fields
     else:
         self._out[field_id] = getattr(self.Address, real_field_id)
Ejemplo n.º 3
0
 def getSalesRelationFields(self, index, field_id):
     # Check if Relation Field...
     if not self.isSalesRelationFields(field_id):
         return
     # ==================================================================== #
     # Sale Person Name
     if field_id == "user_id":
         self._out[field_id] = M2OHelper.get_name(self.object, "user_id")
         self._in.__delitem__(index)
     # ==================================================================== #
     # Sale Person Email
     if field_id == "user_email":
         self._out[field_id] = M2OHelper.get_name(self.object, "user_id",
                                                  "email")
         self._in.__delitem__(index)
     # ==================================================================== #
     # Sale Team Name
     if field_id == "team_id":
         self._out[field_id] = M2OHelper.get_name(self.object, "team_id")
         self._in.__delitem__(index)
Ejemplo n.º 4
0
 def getCarrierFields(self, index, field_id):
     # ====================================================================#
     # Delivery Carrier Name
     if field_id == "carrier_id":
         self._out[field_id] = M2OHelper.get_name(self.object, field_id)
         self._in.__delitem__(index)
     # ====================================================================#
     # Delivery Carrier Description
     if field_id == "carrier_desc":
         self._out[
             field_id] = self.object.carrier_id.name if self.object.carrier_id.id else None
         self._in.__delitem__(index)
Ejemplo n.º 5
0
 def getRelationFields(self, index, field_id):
     # Check if Relation Field...
     if not self.isRelationFields(field_id):
         return
     # ==================================================================== #
     # Categorie
     if field_id == "categ_id":
         self._out[field_id] = M2OHelper.get_id(self.object, "categ_id")
         self._in.__delitem__(index)
     if field_id == "categ":
         self._out[field_id] = M2OHelper.get_name(self.object, "categ_id")
         self._in.__delitem__(index)
     # ==================================================================== #
     # Routes
     if field_id == "route_ids":
         self._out[field_id] = M2MHelper.get_ids(self.object, "route_ids")
         self._in.__delitem__(index)
     if field_id == "routes":
         self._out[field_id] = M2MHelper.get_names(self.object, "route_ids")
         self._in.__delitem__(index)
     # ==================================================================== #
     # Public Categories
     if field_id == "public_categ_ids":
         self._out[field_id] = M2MHelper.get_ids(self.object,
                                                 "public_categ_ids")
         self._in.__delitem__(index)
     if field_id == "public_categ":
         self._out[field_id] = M2MHelper.get_names(self.object,
                                                   "public_categ_ids")
         self._in.__delitem__(index)
     # ==================================================================== #
     # Website Alternate Products
     if field_id == "alternative_products":
         self._out[field_id] = M2MHelper.get_names(
             self.object, "alternative_product_ids")
         self._in.__delitem__(index)
     # ==================================================================== #
     # Website Accessory Products
     if field_id == "accessory_products":
         self._out[field_id] = M2MHelper.get_names(self.object,
                                                   "accessory_product_ids")
         self._in.__delitem__(index)
     # ==================================================================== #
     # Allowed Companies
     if field_id == "company_ids":
         self._out[field_id] = M2MHelper.get_ids(self.object,
                                                 "ons_allowed_company_ids")
         self._in.__delitem__(index)
     if field_id == "company_names":
         self._out[field_id] = M2MHelper.get_names(
             self.object, "ons_allowed_company_ids")
         self._in.__delitem__(index)
     # ==================================================================== #
     # Product Brand
     if field_id == "product_brand_id":
         self._out[field_id] = M2OHelper.get_id(self.object,
                                                "product_brand_id")
         self._in.__delitem__(index)
     if field_id == "product_brand":
         self._out[field_id] = M2OHelper.get_name(self.object,
                                                  "product_brand_id")
         self._in.__delitem__(index)