tsolucio / corebos

core Business Operating System. An OPEN SOURCE business application that helps small and medium business handle all the day to day tasks.
https://corebos.com
151 stars 142 forks source link

Multiple Companies or Brands #1333

Open dfanaei opened 2 years ago

dfanaei commented 2 years ago

Hi. I see there is a companies module. I am trying to create 2 different brands that will be under the same company but will need to show different information in the documents. for example, if I am sending the invoice to a client under brand 2, I want it to show the Brand 2 logo, website, email etc. How is this possible? What is the point of the "Companies" Module in general?

joebordes commented 2 years ago

The companies module was created for this purpose but the project hasn't evolved much. There aren't many users with this need, so, for the moment, it is just a starting point.

I would recommend you try adding a reference field to the company module in the invoice (for example) and then create the GenDoc template to access the information of the logo and address through that field instead of using the default company. That should permit you to automatically generate the correct output depending on the company that the invoice record is related to.

keep asking

dfanaei commented 2 years ago

Thanks for the Reply @joebordes Connecting each invoice to a company is a lot of work and in the heat of the day it will be missed. Is there a way to connect the customer account to the brand/company and then have the document figure out the brand from the customer that is connected to the invoice?

dfanaei commented 2 years ago

Also, Can you please let me know which special variable works to fetch the company logo? I tried these but none worked.

{image cbCompany.companylogo}

{image cbCompany.companylogo}

joebordes commented 2 years ago

Adding the company to the account and copying it to the invoice will work for sure. So you add a relation field on both the Account and the Invoice and then you fill in the company field in the invoice with the field from the Account. That will work. Getting the company from the Account in GenDoc should be possible also using the foreach directive

dfanaei commented 2 years ago

ok sounds good @joebordes . I am still stuck trying to figure out how to get gendoc to grab the Company logo. I use the image directive but it's not working.

{image cbCompany.companylogo}

{image cbCompany.companylogo}

joebordes commented 2 years ago

Apply this change and then define the image as shown in this template: 44865_GenDocCompanyTemplate.odt

Let me know how it goes

dfanaei commented 2 years ago

@joebordes It doesn't work. image Error when trying to open the generated doc.

and this is what the template looks like: image

joebordes commented 2 years ago

almost for sure there are formatting issues in some tags, that is a pain, but it is how it works. try using the debug output in the direct access to Generate Documents, see if that gives us some clue.

If you can share the template also I can give it a try

dfanaei commented 2 years ago

Invoice_Template.odt

I don't think it is a formatting issue. Every time I use {image cbCompany.companylogo} the pdf doesn't ever open and it gives me the error.

dfanaei commented 2 years ago

even trying to use the {ifexists} Directive, it doesn't work.

I am basically trying to tell it to show the logo A if the connected company is Company A and show logo B if the connected company is B.

{ifexists cbCompany=cmp-0000001} A {/ifexists} {ifexists cbCompany=cmp-0000002} B {/ifexists}

OR

{ifexists cbCompany.cbcompanyno=cmp-0000001} A {/ifexists} {ifexists cbCompany.cbcompanyno=cmp-0000004} B {/ifexists}

None of these work.

I am pretty much stuck figuring this out as none of the ways are working.

joebordes commented 2 years ago

The template I sent you uses Organization.companylogo not cbCompany. The special Organization entity captures the default cbCompany record. Can you try with that in your template?

That said, I suppose you have a uitype 10 field related to cbCompany in the Invoice which is the one you want to use for your template. Right? I did that and your template worked.

joebordes commented 2 years ago

ifexists directive is looking for related records in the related list, it just looks if a record with that condition exists in the given module, so if you actually have those two records in your coreBOS, cmp-0000001 and cmp-0000004, related to the record, both conditions will work always. But that would require a related list, not a uitype 10.

The syntax {ifexists cbCompany} checks for any related record The syntax {ifexists cbCompany.cbcompanyno=cmp-0000001} checks for a related record with that field value.

In short, this is not what you are looking for. Add the uitype 10

dfanaei commented 2 years ago

Tried this:

{Organization.companylogo} {image Organization.companylogo} ACTUAL PICTURE

and it still doesn't work It comes out blank, the only thing that works is the first line and it only changes to the picture name (Text format).

dfanaei commented 2 years ago

also, I definitly don't understand what you mean by uitype 10

joebordes commented 2 years ago

see if this helps: https://youtu.be/MrSZEia2Ftc

joebordes commented 2 years ago

pull before you try again, I left a debug message which breaks the output

dfanaei commented 2 years ago

Thanks for the video @joebordes. I do everything based on your instructions. That last pull fixed the error. But the logo is still blank in the pdf. {cbCompany.companylogo} shows as "PICTURENAME.png" but

{image cbCompany.companylogo} IMAGE

is still shown blank.

I also tried creating a custom field for an image in the companies module and did both companies the same image size as the substitute image size. Refer to the SS Below

image

but this is what I get in the output:

image

joebordes commented 2 years ago

at this point, I can only offer a support ticket so we can connect to your installation and see what is happening. Contact me if you are interested.